parent
a88724c0c4
commit
fdde82379b
@ -1,50 +0,0 @@
|
||||
[% USE JSON.Escape( pretty => 0 ) %]
|
||||
[%-
|
||||
#USE Dumper;
|
||||
|
||||
#we can't use DEFAULT directive - it treats false the same as undefined, which doesn't allow to keep default filled values and switch them off by customization
|
||||
MACRO clearHelper BLOCK;
|
||||
FOREACH identifier in [ 'messages', 'length_change', 'dt_columns', 'close_target', 'create_flag', 'form_object', 'ajax_uri' ];
|
||||
helper.${identifier} = '';
|
||||
END;
|
||||
END;
|
||||
MACRO initHelper(var,value) BLOCK;
|
||||
# Dumper.dump(helper);
|
||||
identifier = "${helper.identifier}" _ "_" _ var;
|
||||
UNLESS helper.${var}.defined; helper.${var} = helper.${var} || value || ${"${identifier}"} || ${var}; END;
|
||||
END;
|
||||
MACRO initDtColumns BLOCK;
|
||||
FOR col in helper.dt_columns;
|
||||
IF ! col.accessor;
|
||||
col.accessor = col.name.replace('\.','_');
|
||||
END;
|
||||
END;
|
||||
END;
|
||||
MACRO initHelperAuto BLOCK;
|
||||
FOREACH identifier in [ 'messages', 'length_change', 'dt_columns', 'close_target', 'create_flag' ];
|
||||
initHelper(identifier);
|
||||
END;
|
||||
#;
|
||||
initHelper('form_object',form);
|
||||
initHelper('ajax_uri', c.uri_for( c.controller.action_for('ajax') ));
|
||||
IF ! helper.ajax_uri.search('[\?&]dt_columns=');
|
||||
initDtColumns();
|
||||
helper.dt_columns_json = helper.dt_columns.json() | url;
|
||||
helper.ajax_uri = helper.ajax_uri _ '?dt_columns=' _ helper.dt_columns_json;
|
||||
END;
|
||||
END;
|
||||
|
||||
IF !no_auto_helper;
|
||||
clearHelper();
|
||||
initHelperAuto();
|
||||
#here we can generate couple of variants, selection of proper variant will be exact view responsibility
|
||||
UNLESS c.user.read_only;
|
||||
initHelper('dt_buttons',[
|
||||
{ name = c.loc('Edit'), uri = "/${helper.identifier}'+full[\"id\"]+'/edit", class = 'btn-small btn-primary', icon = 'icon-edit' },
|
||||
] );
|
||||
initHelper('top_buttons',[
|
||||
{ name = c.loc("Create ${helper.name_single}"), uri = c.uri_for("/${helper.identifier}/create"), icon = 'icon-star' },
|
||||
] );
|
||||
END;
|
||||
END;
|
||||
-%]
|
||||
Loading…
Reference in new issue