diff --git a/static/uijs/formbase.js b/static/uijs/formbase.js new file mode 100644 index 0000000000000000000000000000000000000000..eadb1228f1ff808d43873b96901f188a9cae55fc --- /dev/null +++ b/static/uijs/formbase.js @@ -0,0 +1,46 @@ +/* + * /static/uijs/common/form.js + * + * A set of common configuration used in the form + * $id$ + * + */ + +function DefaultCfgForm(){ + this.labelWidth = 75; + this.frame = true; + this.bodyStyle = 'padding:5px 5px 0'; + this.width = 350; + this.defaults = {width: 230}; + this.defaultType = 'textfield'; +}; + +/* + * DefaultSubmitAction + * The form is reset + * When data are succesfully loaded in the database + * + * In case of failure a window popup + * if the return json object contains the alert property + */ +function DefaultSubmitAction(){ + this.clientValidation = true; + this.waitMsg = 'Saving Data...'; + + /* + * Reset the form in case of success + */ + this.success = function(f){ + f.reset() + }; + + /* + * Instanciate the alert window + * if the return object contains the alert property + */ + this.failure = function(f,a){ + if(a.result.alert){ + alert(a.result.alert); + } + }; +} \ No newline at end of file diff --git a/static/uijs/formdistributions.js b/static/uijs/formdistributions.js new file mode 100644 index 0000000000000000000000000000000000000000..b6a655fe0904ce7fc5751a972ed296f198c62e16 --- /dev/null +++ b/static/uijs/formdistributions.js @@ -0,0 +1,54 @@ +/* + * /static/uijs/distributions/form.js + * + * Form associate to the distributions table + * common configurations and actions are defined in /static/uijs/common/form.js + * + * $id$ + * + */ + +Ext.onReady(function(){ + + Ext.QuickTips.init(); + + // turn on validation errors beside the field globally + Ext.form.Field.prototype.msgTarget = 'side'; + + // default configuration and action + var cfgForm = new DefaultCfgForm(); + var submitAction = new DefaultSubmitAction(); + + // Specify title, fields and action + cfgForm.title = 'Distribution'; + cfgForm.items = [ + { + fieldLabel: 'Version', + name: 'version', + allowBlank:false + }, + new Ext.form.DateField({ + fieldLabel: 'Date', + name: 'date', + format:'Y-m-d' + }), + new Ext.form.TextArea({ + fieldLabel: 'Note', + name: 'note', + grow: true + }) + ]; + submitAction.url = '/mdvPostInstall/database/insert?table=distributions' + + // create the form + var distributionForm = new Ext.FormPanel(cfgForm); + var submit = distributionForm.addButton({ + text: 'Submit', + handler: function(){distributionForm.getForm().submit(submitAction);} + }); + + // render the form + distributionForm.render(document.body); + +}); + diff --git a/static/uijs/formrpmCategories.js b/static/uijs/formrpmCategories.js new file mode 100644 index 0000000000000000000000000000000000000000..e7a62318219d4e5545dedaef414a15d356557440 --- /dev/null +++ b/static/uijs/formrpmCategories.js @@ -0,0 +1,49 @@ +/* + * /static/uijs/rpmCategories/form.js + * + * Form associate to the rpmCategories table + * common configurations and actions are defined in /static/uijs/common/form.js + * + * $id$ + * + */ + +Ext.onReady(function(){ + + Ext.QuickTips.init(); + + // turn on validation errors beside the field globally + Ext.form.Field.prototype.msgTarget = 'side'; + + // default configuration and action + var cfgForm = new DefaultCfgForm(); + var submitAction = new DefaultSubmitAction(); + + // spedified title, fields and action + cfgForm.title = 'Rpm Category'; + cfgForm.items = [ + { + fieldLabel: 'Name', + name: 'category', + allowBlank:false + }, + new Ext.form.TextArea({ + fieldLabel: 'Note', + name: 'note', + grow: true + }) + ]; + submitAction.url = '/mdvPostInstall/database/insert?table=rpmCategories' + + // create the form + var distributionForm = new Ext.FormPanel(cfgForm); + var submit = distributionForm.addButton({ + text: 'Submit', + handler: function(){distributionForm.getForm().submit(submitAction);} + }); + + // render the form + distributionForm.render(document.body); + +}); + diff --git a/static/uijs/formrpms.js b/static/uijs/formrpms.js new file mode 100644 index 0000000000000000000000000000000000000000..9fc0d5f4b4494ff7a8606f9d22f1689abcd8eec4 --- /dev/null +++ b/static/uijs/formrpms.js @@ -0,0 +1,89 @@ +/* + * /static/uijs/rpms/form.js + * + * Form associate to the rpms table + * common configurations and actions are defined in /static/uijs/common/form.js + * + * $id$ + * + */ + +Ext.onReady(function(){ + + Ext.QuickTips.init(); + + // turn on validation errors beside the field globally + Ext.form.Field.prototype.msgTarget = 'side'; + + // default configuration and action + var cfgForm = new DefaultCfgForm(); + var submitAction = new DefaultSubmitAction(); + + // create a data store for the category combobox + var categoriesStore = new Ext.data.JsonStore({ + url: '/mdvPostInstall/database/select?table=rpmCategories&orderby=category', + fields: ['id', 'category'] + }); + + // create a data store for the distribution combobox + var distributionsStore = new Ext.data.JsonStore({ + url: '/mdvPostInstall/database/select?table=distributions&orderby=version', + fields: ['id', 'version'] + }); + + // Specify title, fields and action + cfgForm.title = 'Rpm'; + cfgForm.items = [ + { + fieldLabel: 'Name', + name: 'rpm', + allowBlank: false + }, + new Ext.form.ComboBox({ + fieldLabel: 'Category', + hiddenName: 'idcategory', + valueField: 'id', + displayField: 'category', + store: categoriesStore, + typeAhead: true, + mode: 'remote', + triggerAction: 'all', + emptyText: 'Select a category...', + selectOnFocus: true + }), + new Ext.form.ComboBox({ + fieldLabel: 'Distribution', + hiddenName: 'iddistribution', + valueField: 'id', + displayField: 'version', + store: distributionsStore, + typeAhead: true, + mode: 'remote', + triggerAction: 'all', + emptyText: 'Select a version...', + selectOnFocus: true + }), + { + xtype: 'radiogroup', + fieldLabel: 'List', + columns: 1, + items: [ + {boxLabel: 'add', name: 'list', inputValue: 'add', checked: true}, + {boxLabel: 'remove', name: 'list', inputValue: 'remove'} + ] + } + ]; + submitAction.url = '/mdvPostInstall/database/insert?table=rpms' + + // create the form + var distributionForm = new Ext.FormPanel(cfgForm); + var submit = distributionForm.addButton({ + text: 'Submit', + handler: function(){distributionForm.getForm().submit(submitAction);} + }); + + // render the form + distributionForm.render(document.body); + +}); + diff --git a/static/uijs/formsystems.js b/static/uijs/formsystems.js new file mode 100644 index 0000000000000000000000000000000000000000..85ec9f070f78d944be6ca9d587d32c8d81d8ec97 --- /dev/null +++ b/static/uijs/formsystems.js @@ -0,0 +1,49 @@ +/* + * /static/uijs/systems/form.js + * + * Form associate to the systems table + * common configurations and actions are defined in /static/uijs/common/form.js + * + * $id$ + * + */ + +Ext.onReady(function(){ + + Ext.QuickTips.init(); + + // turn on validation errors beside the field globally + Ext.form.Field.prototype.msgTarget = 'side'; + + // default configuration and action + var cfgForm = new DefaultCfgForm(); + var submitAction = new DefaultSubmitAction(); + + // Specify title, fields and action + cfgForm.title = 'System'; + cfgForm.items = [ + { + fieldLabel: 'Name', + name: 'system', + allowBlank:false + }, + new Ext.form.TextArea({ + fieldLabel: 'Note', + name: 'note', + grow: true + }) + ]; + submitAction.url = '/mdvPostInstall/database/insert?table=systems' + + // create the form + var distributionForm = new Ext.FormPanel(cfgForm); + var submit = distributionForm.addButton({ + text: 'Submit', + handler: function(){distributionForm.getForm().submit(submitAction);} + }); + + // render the form + distributionForm.render(document.body); + +}); +