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

cleanup/method renaming

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