Commit 3c2c8724 authored by Sven Franck's avatar Sven Franck

cleanup/method renaming

parent 616a1f27
...@@ -1921,7 +1921,7 @@ ...@@ -1921,7 +1921,7 @@
promises = []; promises = [];
// fetch content // fetch content
app.fetchConfiguration({ app.fetchConfig({
"storage": app.default_dict.storage_dict.settings, "storage": app.default_dict.storage_dict.settings,
"file": app.default_dict.storage_dict.gadgets, "file": app.default_dict.storage_dict.gadgets,
"attachment": reference, "attachment": reference,
...@@ -4562,7 +4562,7 @@ ...@@ -4562,7 +4562,7 @@
); );
// need field values for allDocs select_list... // need field values for allDocs select_list...
return app.fetchConfiguration({ return app.fetchConfig({
"storage": app.default_dict.storage_dict.settings, "storage": app.default_dict.storage_dict.settings,
"file": app.default_dict.storage_dict.data_type, "file": app.default_dict.storage_dict.data_type,
"attachment": "person_fieldlist", "attachment": "person_fieldlist",
...@@ -5601,17 +5601,17 @@ ...@@ -5601,17 +5601,17 @@
/** /**
* Generate gadget content based on query data and passed config * Generate gadget content based on query data and passed config
* @method generateGadgetContent * @method makeContent
* @param {object} reply Response from previous promise and pass-params * @param {object} reply Response from previous promise and pass-params
* @return {object} response object/promise * @return {object} response object/promise
*/ */
app.generateGadgetContent = function (reply) { app.makeContent = function (reply) {
var selector, element, pass, constructor, data, data_set; var selector, element, pass, constructor, data, data_set;
pass = reply.pass; pass = reply.pass;
constructor = map.gadgets[pass.constructor]; constructor = map.gadgets[pass.constructor];
if (constructor === undefined) { if (constructor === undefined) {
return util.error("generateGadgetContent: Missing constructor"); return util.error("makeContent: Missing constructor");
} }
// set data depending on auth // set data depending on auth
...@@ -5870,7 +5870,7 @@ ...@@ -5870,7 +5870,7 @@
} }
// TODO: bad way to set attachment value!! // TODO: bad way to set attachment value!!
return app.fetchConfiguration({ return app.fetchConfig({
"storage": app.default_dict.storage_dict.settings, "storage": app.default_dict.storage_dict.settings,
"file": app.default_dict.storage_dict.data_type, "file": app.default_dict.storage_dict.data_type,
"attachment": pass.type.toLowerCase() + "_fieldlist", "attachment": pass.type.toLowerCase() + "_fieldlist",
...@@ -5964,11 +5964,11 @@ ...@@ -5964,11 +5964,11 @@
/** /**
* If no data is found in JIO, we need to load fake data for now * If no data is found in JIO, we need to load fake data for now
* @method retrieveSampleData * @method fetchDataSample
* @param {object} reply Response from previous promise and pass-params * @param {object} reply Response from previous promise and pass-params
* @return {object} response object/promise * @return {object} response object/promise
*/ */
app.retrieveSampleData = function (reply) { app.fetchDataSample = function (reply) {
var pass = reply.pass; var pass = reply.pass;
if (reply.response) { if (reply.response) {
...@@ -5992,11 +5992,11 @@ ...@@ -5992,11 +5992,11 @@
/** /**
* Test if JIO has data of a certain portal_type * Test if JIO has data of a certain portal_type
* @method testStorageForData * @method testDataSample
* @param {object} reply Response from previous promise and pass-params * @param {object} reply Response from previous promise and pass-params
* @return {object} response object/promise * @return {object} response object/promise
*/ */
app.testStorageForData = function (reply) { app.testDataSample = function (reply) {
var pass = reply.pass; var pass = reply.pass;
if (pass.skip === undefined) { if (pass.skip === undefined) {
...@@ -6022,11 +6022,11 @@ ...@@ -6022,11 +6022,11 @@
// ======================== SAMPLE DATA ================================== // ======================== SAMPLE DATA ==================================
/** /**
* Load field definitions if necessary * Load field definitions if necessary
* @method loadFieldDefinition * @method fetchFields
* @param {object} pass through * @param {object} pass through
* @return {object} field defintions and pass through * @return {object} field defintions and pass through
*/ */
app.loadFieldDefinition = function (reply) { app.fetchFields = function (reply) {
var pass = reply.pass; var pass = reply.pass;
// active login? // active login?
...@@ -6046,7 +6046,7 @@ ...@@ -6046,7 +6046,7 @@
// TODO: keep this until sample handling is removed // TODO: keep this until sample handling is removed
pass.needs_fields = true; pass.needs_fields = true;
return app.fetchConfiguration({ return app.fetchConfig({
"storage": app.default_dict.storage_dict.settings, "storage": app.default_dict.storage_dict.settings,
"file": app.default_dict.storage_dict.data_type, "file": app.default_dict.storage_dict.data_type,
"attachment": pass.config.portal_type_fields, "attachment": pass.config.portal_type_fields,
...@@ -6060,11 +6060,11 @@ ...@@ -6060,11 +6060,11 @@
/** /**
* parses a gadget configuration file * parses a gadget configuration file
* @method parseConfiguration * @method checkAuth
* @param {object} reply gadget configuration * @param {object} reply gadget configuration
* @return {object} response object/promise * @return {object} response object/promise
*/ */
app.parseConfiguration = function (reply) { app.checkAuth = function (reply) {
var parsed, pass = reply.pass; var parsed, pass = reply.pass;
if (pass.skip === undefined) { if (pass.skip === undefined) {
...@@ -6144,7 +6144,6 @@ ...@@ -6144,7 +6144,6 @@
"create": create, "create": create,
"layout_level": spec.layout_level || null, "layout_level": spec.layout_level || null,
"fragment_list": spec.fragment_list, "fragment_list": spec.fragment_list,
// TODO: this should be a link!
"href": content_dict.href, "href": content_dict.href,
"reference": content_dict.reference || null "reference": content_dict.reference || null
}; };
...@@ -6156,21 +6155,21 @@ ...@@ -6156,21 +6155,21 @@
} }
// and go // and go
return app.fetchConfiguration({ return app.fetchConfig({
"storage": app.default_dict.storage_dict.settings, "storage": app.default_dict.storage_dict.settings,
"file": pass.href ? app.default_dict.storage_dict.gadgets : "file": pass.href ? app.default_dict.storage_dict.gadgets :
app.default_dict.storage_dict.settings, app.default_dict.storage_dict.settings,
"attachment": pass.href || app.default_dict.storage_dict.configuration, "attachment": pass.href || app.default_dict.storage_dict.configuration,
"pass": pass "pass": pass
}) })
.then(app.parseConfiguration) .then(app.checkAuth)
.then(app.loadFieldDefinition) .then(app.fetchFields)
.then(app.testStorageForData) .then(app.testDataSample)
.then(app.retrieveSampleData) .then(app.fetchDataSample)
.then(app.store) .then(app.store)
.then(app.fetchDataTotal) .then(app.fetchDataTotal)
.then(app.fetchDataQuery) .then(app.fetchDataQuery)
.then(app.generateGadgetContent) .then(app.makeContent)
.fail(util.error); .fail(util.error);
default: default:
...@@ -6197,11 +6196,11 @@ ...@@ -6197,11 +6196,11 @@
/** /**
* Fetch a configuration file (attachment) from storage. Fallback to * Fetch a configuration file (attachment) from storage. Fallback to
* disk. Successfull fallback file fetches will be stored in JIO. * disk. Successfull fallback file fetches will be stored in JIO.
* @method fetchConfiguration * @method fetchConfig
* @param {object} parcel parameters & pass to pass to subsequent then() * @param {object} parcel parameters & pass to pass to subsequent then()
* @return {object} object including pass and reply * @return {object} object including pass and reply
*/ */
app.fetchConfiguration = function (parcel) { app.fetchConfig = function (parcel) {
var reply, store; var reply, store;
if (parcel.pass && parcel.pass.skip) { if (parcel.pass && parcel.pass.skip) {
...@@ -6232,7 +6231,7 @@ ...@@ -6232,7 +6231,7 @@
function (error) { function (error) {
// if the file is not found in JIO, try to pull from disk // if the file is not found in JIO, try to pull from disk
if (error.status === 404 && error.id === parcel.file) { if (error.status === 404 && error.id === parcel.file) {
return app.getFromDisk({ return app.loadFile({
"store": store, "store": store,
"file": parcel.file, "file": parcel.file,
"attachment": parcel.attachment, "attachment": parcel.attachment,
...@@ -6300,13 +6299,13 @@ ...@@ -6300,13 +6299,13 @@
/** /**
* Load files from disk * Load files from disk
* @method getFromDisk * @method loadFile
* @param {object} property_dict (including pass) * @param {object} property_dict (including pass)
* @return {object} object * @return {object} object
*/ */
// TODO: put/putAttachment should be set somewhere more general! // TODO: put/putAttachment should be set somewhere more general!
// TODO: refactor... such a mess // TODO: refactor... such a mess
app.getFromDisk = function (property_dict) { app.loadFile = function (property_dict) {
var response, storage_location, url, hacked_view; var response, storage_location, url, hacked_view;
url = property_dict.url || app.default_dict.path_dict.data + url = property_dict.url || app.default_dict.path_dict.data +
...@@ -6317,7 +6316,7 @@ ...@@ -6317,7 +6316,7 @@
if (property_dict.optional) { if (property_dict.optional) {
return RSVP.all([]); return RSVP.all([]);
} }
util.error("getFromDisk: URL undefined"); util.error("loadFile: URL undefined");
} }
// fetch file // fetch file
...@@ -6341,7 +6340,7 @@ ...@@ -6341,7 +6340,7 @@
} }
if (storage_location === undefined) { if (storage_location === undefined) {
util.error("getFromDisk: no storage defined"); util.error("loadFile: no storage defined");
return RSVP.all([]); return RSVP.all([]);
} }
...@@ -6459,7 +6458,7 @@ ...@@ -6459,7 +6458,7 @@
destination = config.layout_identifier; destination = config.layout_identifier;
} }
return app.fetchConfiguration({ return app.fetchConfig({
"storage": app.default_dict.storage_dict.settings, "storage": app.default_dict.storage_dict.settings,
"file": "pages", "file": "pages",
"attachment": destination, "attachment": destination,
...@@ -6722,11 +6721,11 @@ ...@@ -6722,11 +6721,11 @@
/** /**
* Retrieve application configuration from path specified on the * Retrieve application configuration from path specified on the
* JavaScript file loaded (thx http://requirejs.org) * JavaScript file loaded (thx http://requirejs.org)
* @method getPathFromScriptTag * @method fetchPath
* @param {string} attribute Attribute to find * @param {string} attribute Attribute to find
* @return {string} path * @return {string} path
*/ */
util.getPathFromScriptTag = function (attribute) { util.fetchPath = function (attribute) {
var i, path, script_list = document.getElementsByTagName("script"); var i, path, script_list = document.getElementsByTagName("script");
for (i = 0; i < script_list.length; i += 1) { for (i = 0; i < script_list.length; i += 1) {
...@@ -6983,31 +6982,11 @@ ...@@ -6983,31 +6982,11 @@
* Return * Return
* @method return * @method return
*/ */
// TODO: remove only used for JSLint and validval // TODO: remove only used for JSLint for validval
util.return_out = function () { util.return_out = function () {
return; return;
}; };
/**
* escape a urlString
* @method encode
* @param {string} string String to escape
* @return {string} escaped string
**/
util.encode = function (string) {
return encodeURIComponent(string);
};
/**
* decode a urlString
* @method decode
* @param {string} string String to unescape
* @return {string} unescaped string
**/
util.decode = function (string) {
return decodeURIComponent(string);
};
/** /**
* parse to JSON if element is not in JSON * parse to JSON if element is not in JSON
* @parseIfNeeded * @parseIfNeeded
...@@ -7075,7 +7054,7 @@ ...@@ -7075,7 +7054,7 @@
* @method error * @method error
* @param {object} err Error object * @param {object} err Error object
*/ */
// TODO: update global config so we know where to post a ticket to! // TODO: Post a ticket to ...
util.error = function (err) { util.error = function (err) {
if (typeof err === "string") { if (typeof err === "string") {
console.log({"error": err}); console.log({"error": err});
...@@ -7089,21 +7068,21 @@ ...@@ -7089,21 +7068,21 @@
/* ====================================================================== */ /* ====================================================================== */
app.contentLoaded(window, function () { app.contentLoaded(window, function () {
// TODO: don't wipe. Sync...! // TODO: Don't wipe. Wait for sync...!
// Don't wipe if opened in a popup (like in oAuth redirect_uri) // NOTE: Don't clear if page is opened in popup (like when using oauth)
if (window.opener === null) { if (window.opener === null) {
window.localStorage.clear(); window.localStorage.clear();
} }
app.getFromDisk({ app.loadFile({
"url": util.getPathFromScriptTag("data-storage"), "url": util.fetchPath("data-storage"),
"optional": true, "optional": true,
"skip": true "skip": true
}) })
.then(app.setContent) .then(app.setContent)
.then(function () { .then(function () {
return app.getFromDisk({ return app.loadFile({
"url": util.getPathFromScriptTag("data-config") "url": util.fetchPath("data-config")
}); });
}) })
.then(app.setContent) .then(app.setContent)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment