#wip: Fixing ECMA UI.
This commit is contained in:
parent
d4f7dd60c9
commit
ebe451c88a
@ -39,6 +39,13 @@ export const AnP = (function(){
|
||||
* @return {boolean}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @callback execute_action_callback
|
||||
* @param {?(Object.<string, any|null>|Array.<any|null>)} [data = null]
|
||||
* @param {!number} [code = 200]
|
||||
* @returns {any|null|void}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @constructs AnP
|
||||
* @param {?(Object.<string, any|null>|Array<any|null>)} [inputs = null]
|
||||
@ -204,6 +211,21 @@ export const AnP = (function(){
|
||||
*/
|
||||
this.exception = (exception, message, inputs = null, i = 0) => {};
|
||||
|
||||
/**
|
||||
* @param {!(string|[string, string]|execute_action_callback)} action
|
||||
* @param {?(Object.<string, any|null>|Array.<any|null>)} [data = null]
|
||||
* @param {!number} [code = 200]
|
||||
* @returns {any|null|void}
|
||||
* @access public
|
||||
*/
|
||||
this.execute = (action, data = null, code = 200) => {
|
||||
if(Check.is_string(action) || Check.is_array(action))
|
||||
return self.controllers.execute(action, data, code);
|
||||
if(Check.is_function(action))
|
||||
return action(data, code);
|
||||
return null;
|
||||
};
|
||||
|
||||
constructor();
|
||||
|
||||
};
|
||||
|
||||
@ -66,7 +66,17 @@ export const FormsComponent = (function(){
|
||||
...(view ? {data_view : view} : {}),
|
||||
method : Common.get_value("method", inputs, "post"),
|
||||
action : Common.get_value("action", inputs, "#"),
|
||||
...(submit ? {on_submit : submit} : {})
|
||||
on_submit : (item, event) => {
|
||||
|
||||
event.preventDefault();
|
||||
|
||||
anp.execute(submit, {
|
||||
item : item,
|
||||
event : event
|
||||
});
|
||||
|
||||
return false;
|
||||
}
|
||||
}, [
|
||||
Fieldset({class : "form"}, [
|
||||
anp.components.i18n(name, "legend"),
|
||||
@ -92,7 +102,7 @@ export const FormsComponent = (function(){
|
||||
for : id,
|
||||
data_i18n : name,
|
||||
data_i18n_without : true,
|
||||
title : anp.components.i18n(name, "label")
|
||||
title : anp.i18n.get(name, "label")
|
||||
}, [
|
||||
anp.components.i18n(name),
|
||||
anp.components.i18n(name + "_description"),
|
||||
@ -104,10 +114,13 @@ export const FormsComponent = (function(){
|
||||
]);
|
||||
})),
|
||||
UL({class : "global-errors"}),
|
||||
Div({class : "buttons"}, Common.get_value(["actions", "buttons"], inputs, []).concat(
|
||||
[anp.components.button(Common.get_value("submit_reset", inputs, "clean"), "reset")],
|
||||
submit ? [anp.components.button(Common.get_value("submit_name", inputs, "submit"), "submit")] : []
|
||||
))
|
||||
Div({class : "buttons"}, Common.get_value(["actions", "buttons"], inputs, []).concat([
|
||||
anp.components.button(Common.get_value("submit_cancel", inputs, "cancel"), (item, event) => {
|
||||
anp.routes.back();
|
||||
}),
|
||||
anp.components.button(Common.get_value("submit_reset", inputs, "clean"), "reset"),
|
||||
submit ? anp.components.button(Common.get_value("submit_name", inputs, "submit"), "submit") : null
|
||||
]))
|
||||
])
|
||||
]);
|
||||
};
|
||||
|
||||
@ -32,11 +32,17 @@ export const SessionsController = (function(){
|
||||
*/
|
||||
const constructor = () => {};
|
||||
|
||||
this.login = () => {};
|
||||
this.login = () => {
|
||||
console.log("PASA login");
|
||||
};
|
||||
|
||||
this.logout = () => {};
|
||||
this.logout = () => {
|
||||
console.log("PASA logout");
|
||||
};
|
||||
|
||||
this.register = () => {};
|
||||
this.register = () => {
|
||||
console.log("PASA register");
|
||||
};
|
||||
|
||||
constructor();
|
||||
};
|
||||
|
||||
@ -154,11 +154,20 @@ export const ControllersManager = (function(){
|
||||
* @param {!string} action
|
||||
* @param {?any} [data = null]
|
||||
* @param {!number} [code = 200]
|
||||
* @return {void}
|
||||
* @return {any|null|void}
|
||||
* @access public
|
||||
*/
|
||||
this.execute = (controller, action, data = null, code = 200) => {
|
||||
controllers[controller] && controllers[controller][action] && controllers[controller][action](data, code);
|
||||
this.execute = (action, data = null, code = 200) => {
|
||||
|
||||
/** @type {[string|null, string|null]} */
|
||||
const [controller, method] = (
|
||||
Check.is_string(action) ? action.split("@") :
|
||||
Check.is_array(action) && action.length == 2 ? action :
|
||||
[null, null]);
|
||||
|
||||
if(controller && method && controllers[controller] && controllers[controller][method])
|
||||
return controllers[controller][method](data, code);
|
||||
return null;
|
||||
};
|
||||
|
||||
constructor();
|
||||
|
||||
@ -42,13 +42,19 @@ export const RoutesManager = (function(){
|
||||
/** @type {RoutesManager} */
|
||||
const self = this,
|
||||
/** @type {Array.<RouteModel>} */
|
||||
routes = [];
|
||||
routes = [],
|
||||
/** @type {Array.<string>} */
|
||||
history = [],
|
||||
/** @type {Array.<string>} */
|
||||
history_post = [];
|
||||
/** @type {boolean} */
|
||||
let started = false,
|
||||
/** @type {string} */
|
||||
last_url = "",
|
||||
/** @type {string|null} */
|
||||
last_url = null,
|
||||
/** @type {number|null} */
|
||||
thread = null;
|
||||
thread = null,
|
||||
/** @type {boolean} */
|
||||
backed = false;
|
||||
|
||||
/**
|
||||
* @returns {void}
|
||||
@ -73,8 +79,17 @@ export const RoutesManager = (function(){
|
||||
const current_url = window.location.hash.substring(1);
|
||||
|
||||
if(last_url != current_url){
|
||||
|
||||
last_url = current_url;
|
||||
|
||||
if(backed){
|
||||
history_post.splice(0, 0);
|
||||
backed = false;
|
||||
}else
|
||||
history.push(current_url);
|
||||
|
||||
self.refresh();
|
||||
|
||||
};
|
||||
|
||||
};
|
||||
@ -241,6 +256,7 @@ export const RoutesManager = (function(){
|
||||
*/
|
||||
this.go = path => {
|
||||
|
||||
/** @type {HTMLMainElement|null} */
|
||||
const main = anp.item_self.querySelector("main");
|
||||
|
||||
if(!main)
|
||||
@ -262,6 +278,17 @@ export const RoutesManager = (function(){
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* @returns {void}
|
||||
* @access public
|
||||
*/
|
||||
this.back = () => {
|
||||
console.log("PASA");
|
||||
backed = true;
|
||||
history_post.push(history.pop());
|
||||
window.location.href = "#" + history[history.length - 1];
|
||||
};
|
||||
|
||||
constructor();
|
||||
};
|
||||
|
||||
|
||||
@ -33,6 +33,7 @@
|
||||
"anpbot" : "AnPBot",
|
||||
"clean" : "Limpiar",
|
||||
"submit" : "Enviar",
|
||||
"cancel" : "Cancelar",
|
||||
|
||||
"AnP_Sessions_start" : null,
|
||||
"login" : "Acceder",
|
||||
|
||||
@ -1237,6 +1237,9 @@
|
||||
height: 1em;
|
||||
margin-right: 0.3em;
|
||||
}
|
||||
.anp .form-component {
|
||||
padding: 1em;
|
||||
}
|
||||
.anp .form-component fieldset {
|
||||
margin: 0em;
|
||||
padding: 0em;
|
||||
|
||||
File diff suppressed because one or more lines are too long
@ -301,6 +301,7 @@
|
||||
}
|
||||
|
||||
.form-component{
|
||||
padding : 1em;
|
||||
fieldset{
|
||||
margin : 0em;
|
||||
padding : 0em;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user