Commit 12a58176 authored by Sven Franck's avatar Sven Franck

starting to make setPageElements global layout handler

parent f6c066bd
......@@ -5,15 +5,25 @@
(function (window, document, $) {
"use strict";
var init, app, util, erp5, factory;
var init, app, util, erp5, factory, map, storage;
/* ====================================================================== */
/* MAPPING ERP5 */
/* STORAGE */
/* ====================================================================== */
/*
* storage object
*/
storage = {};
/* ====================================================================== */
/* MAPPING */
/* ====================================================================== */
/*
* object containing mappering methods
* mapping object for custom (in this case ERP5) backend
*/
map = {};
erp5 = {};
......@@ -3085,9 +3095,9 @@
};
/**
* sets up JIO based on loaded JSON "recipe"
* set up storages based on fetched recipee
* @method createStorages
* @param {object} response object containing data (jio.util.ajax response)
* @param {object} reply Storage recipee
* @return {object} promise object
*/
app.createStorages = function (reply) {
......@@ -3095,13 +3105,11 @@
store,
promises = [];
app.storages = {};
for (i = 0; i < reply.length; i += 1) {
store = reply[i].definition;
promises[i] =
app.storages[store.application_name] =
storage[store.application_name] =
jIO.createJIO(store);
}
return RSVP.all(promises);
......@@ -3167,7 +3175,7 @@
// TODO should be generic, not only JIO based!
init.fetchConfiguration = function (parcel) {
//storage, file, attachment, baggage
var reply, store = app.storages[parcel.storage];
var reply, store = storage[parcel.storage];
return store.getAttachment({
"_id": parcel.file,
......@@ -3209,7 +3217,7 @@
*/
// NOTE: until we have real data we load fake data on application init!
init.fetchData = function (parcel) {
return app.storages[parcel.storage].allDocs(parcel.query)
return storage[parcel.storage].allDocs(parcel.query)
.then(function (response) {
return {
"response": response,
......@@ -3584,7 +3592,7 @@
init.timer = window.setTimeout(function () {
// update gadgets
init.setPageElements(
{}, [{"children": [{"id": config.id}]}], false
[{"children": [{"id": config.id}]}], {}, false
);
init.timer = 0;
}, 500);
......@@ -3628,7 +3636,7 @@
// update gadget
init.setPageElements(
{}, [{"children": [{"id": action_dict.id}]}], false
[{"children": [{"id": action_dict.id}]}], {}, false
);
})
.fail(util.errorHandler);
......@@ -3884,7 +3892,7 @@
// update gadget
init.setPageElements(
{}, [{"children": [{"id": config.id}]}], false
[{"children": [{"id": config.id}]}], {}, false
);
} else {
util.errorHandler({
......@@ -3917,7 +3925,7 @@
.then(function (reply) {
if (!page.querySelectorAll("div.ui-content")[0]
.getAttribute("data-bound")) {
return init.setPageElements({"id": page.id}, reply, undefined);
return init.setPageElements(reply, {"id": page.id}, undefined);
}
})
.fail(util.errorHandler);
......@@ -4088,7 +4096,7 @@
init.fetchPageLayouts("settings", destination)
.then(function (reply) {
return init.setPageElements(config, reply, create);
return init.setPageElements(reply, config, create);
})
.then(init.setPageBindings)
.fail(util.errorHandler);
......@@ -4205,7 +4213,7 @@
promises,
record,
items,
store = app.storages["items"],
store = storage["items"],
baggage = reply.baggage;
if (reply.response) {
......@@ -4393,11 +4401,11 @@
/**
* Setup/update elements to on the page being shown, generate page
* @method setupPageElements
* @param {object} config JSON pointers based on parsed link
* @param {object} layouts Layouts to be generated for this page
* @param {object} config JSON pointers based on parsed link
* @param {boolean} create Create page/Generate content/Refresh content
*/
init.setPageElements = function (config, layouts, create) {
init.setPageElements = function (layouts, config, create) {
var i,
page,
target,
......@@ -4922,7 +4930,7 @@
window.localStorage.clear();
// TODO: modernizr check and shim here
// TODO: modernizr check and shim based on app.json
// initalize translations
......@@ -4934,7 +4942,7 @@
ns: "dict"
});
// TODO: run this to the normal route!
// TODO: get storage run, get config run, get page run
app.setupStorages(util.getPathFromScriptTag("data-storage"))
.then(init.loadGlobalElements)
.then(init.setupGlobalElements)
......
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