commit f2268f71d582c0dee8771d655435d1b3b8a4095e
parent cc134f6f8a29f18e8ea5573329d3641ab1680cd8
Author: Felicitus <felicitus@felicitus.org>
Date: Fri, 4 Sep 2015 17:52:06 +0200
Set bodyPadding as separate variable, reformatted to match coding standards
Diffstat:
1 file changed, 131 insertions(+), 123 deletions(-)
diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/Components/Editor/Editor.js b/src/PartKeepr/FrontendBundle/Resources/public/js/Components/Editor/Editor.js
@@ -1,137 +1,145 @@
-
Ext.define('PartKeepr.Editor', {
- extend: 'Ext.form.Panel',
- alias: 'widget.Editor',
- trackResetOnLoad: true,
- bodyStyle: 'background:#DBDBDB;padding: 10px;',
- record: null, // The record which is currently edited
- saveText: i18n("Save"),
- cancelText: i18n("Cancel"),
- model: null,
- layout: 'anchor',
- change: false,
- autoScroll: true,
+ extend: 'Ext.form.Panel',
+ alias: 'widget.Editor',
+ trackResetOnLoad: true,
+ bodyPadding: 10,
+ record: null, // The record which is currently edited
+ saveText: i18n("Save"),
+ cancelText: i18n("Cancel"),
+ model: null,
+ layout: 'anchor',
+ change: false,
+ autoScroll: true,
defaults: {
anchor: '100%',
labelWidth: 150
},
enableButtons: true,
-
+
// If false, determinates if we should sync via the store or the record itself.
// If true, always syncs the record via it's own proxy.
syncDirect: false,
-
- onFieldChange: function () {
- return;
-
- // @todo Finish implementing the dirty flag later
- /*if (this.change == false) {
- this.setTitle(this.record.get("name") + "*");
- }
-
- this.change = true;*/
+
+ onFieldChange: function ()
+ {
+ return;
+
+ // @todo Finish implementing the dirty flag later
+ /*if (this.change == false) {
+ this.setTitle(this.record.get("name") + "*");
+ }
+
+ this.change = true;*/
},
- initComponent: function () {
- if (this.enableButtons) {
- this.saveButton = Ext.create("Ext.button.Button", {
- text: this.saveText,
- icon: 'bundles/brainbitsfugueicons/icons/fugue/16/disk.png',
- handler: Ext.bind(this._onItemSave, this)
- });
-
- this.cancelButton = Ext.create("Ext.button.Button", {
- text: this.cancelText,
- icon: 'resources/silkicons/cancel.png',
- handler: Ext.bind(this.onCancelEdit, this)
- });
-
- this.bottomToolbar = Ext.create("Ext.toolbar.Toolbar", {
- enableOverflow: true,
- margin: '10px',
- defaults: {minWidth: 100},
- dock: 'bottom',
- ui: 'footer',
- items: [ this.saveButton, this.cancelButton ]
- });
-
- Ext.apply(this, {
- dockedItems: [ this.bottomToolbar ]});
- }
-
-
-
-
- this.on("dirtychange", function (form, dirty) {
- // @todo Check dirty flag
- // Waiting for reply on http://www.sencha.com/forum/showthread.php?135142-Ext.form.Basic.loadRecord-causes-form-to-be-dirty&p=607588#post607588
- });
-
- this.defaults.listeners = {
- "change": Ext.bind(this.onFieldChange, this)
+ initComponent: function ()
+ {
+ if (this.enableButtons) {
+ this.saveButton = Ext.create("Ext.button.Button", {
+ text: this.saveText,
+ icon: 'bundles/brainbitsfugueicons/icons/fugue/16/disk.png',
+ handler: Ext.bind(this._onItemSave, this)
+ });
+
+ this.cancelButton = Ext.create("Ext.button.Button", {
+ text: this.cancelText,
+ icon: 'resources/silkicons/cancel.png',
+ handler: Ext.bind(this.onCancelEdit, this)
+ });
+
+ this.bottomToolbar = Ext.create("Ext.toolbar.Toolbar", {
+ enableOverflow: true,
+ margin: '10px',
+ defaults: {minWidth: 100},
+ dock: 'bottom',
+ ui: 'footer',
+ items: [this.saveButton, this.cancelButton]
+ });
+
+ Ext.apply(this, {
+ dockedItems: [this.bottomToolbar]
+ });
+ }
+
+
+ this.on("dirtychange", function (form, dirty)
+ {
+ // @todo Check dirty flag
+ // Waiting for reply on http://www.sencha.com/forum/showthread.php?135142-Ext.form.Basic.loadRecord-causes-form-to-be-dirty&p=607588#post607588
+ });
+
+ this.defaults.listeners = {
+ "change": Ext.bind(this.onFieldChange, this)
};
-
- this.callParent();
- },
- onCancelEdit: function () {
- this.fireEvent("editorClose", this);
- },
- newItem: function (defaults) {
- Ext.apply(defaults, {});
- var j = Ext.create(this.model, defaults);
- this.editItem(j);
- },
- editItem: function (record) {
- this.record = record;
- this.getForm().loadRecord(this.record);
- this.show();
- if (this.record.get("name") !== "") {
- this.setTitle(this.record.get("name"));
- }
-
- this.change = false;
- this.fireEvent("startEdit", this);
- },
- getRecordId: function () {
- if (this.record) {
- return this.record.getId();
- } else {
- return null;
- }
- },
- _onItemSave: function () {
- // Disable the save button to indicate progress
- if (this.enableButtons) {
- this.saveButton.disable();
-
- // Sanity: If the save process fails, re-enable the button after 30 seconds
- // @todo This is quite a hack. Needs verification if that's still required
- Ext.defer(function () {
- if (this.saveButton.getEl()) {
- this.saveButton.enable();
- }
- }, 30000, this);
- }
-
- this.getForm().updateRecord(this.record);
-
- this.fireEvent("itemSave", this.record);
-
- this.record.save({
- callback: this._onSave,
- scope: this
- });
- },
- _onSave: function (record, response) {
- if (this.enableButtons) {
- // Re-enable the save button
- this.saveButton.enable();
- }
-
- if (response.success === true) {
- this.record = record;
- this.fireEvent("itemSaved", this.record);
- }
+
+ this.callParent();
+ },
+ onCancelEdit: function ()
+ {
+ this.fireEvent("editorClose", this);
+ },
+ newItem: function (defaults)
+ {
+ Ext.apply(defaults, {});
+ var j = Ext.create(this.model, defaults);
+ this.editItem(j);
+ },
+ editItem: function (record)
+ {
+ this.record = record;
+ this.getForm().loadRecord(this.record);
+ this.show();
+ if (this.record.get("name") !== "") {
+ this.setTitle(this.record.get("name"));
+ }
+
+ this.change = false;
+ this.fireEvent("startEdit", this);
+ },
+ getRecordId: function ()
+ {
+ if (this.record) {
+ return this.record.getId();
+ } else {
+ return null;
+ }
+ },
+ _onItemSave: function ()
+ {
+ // Disable the save button to indicate progress
+ if (this.enableButtons) {
+ this.saveButton.disable();
+
+ // Sanity: If the save process fails, re-enable the button after 30 seconds
+ // @todo This is quite a hack. Needs verification if that's still required
+ Ext.defer(function ()
+ {
+ if (this.saveButton.getEl()) {
+ this.saveButton.enable();
+ }
+ }, 30000, this);
+ }
+
+ this.getForm().updateRecord(this.record);
+
+ this.fireEvent("itemSave", this.record);
+
+ this.record.save({
+ callback: this._onSave,
+ scope: this
+ });
+ },
+ _onSave: function (record, response)
+ {
+ if (this.enableButtons) {
+ // Re-enable the save button
+ this.saveButton.enable();
+ }
+
+ if (response.success === true) {
+ this.record = record;
+ this.fireEvent("itemSaved", this.record);
+ }
this.editItem(record);
- }
+ }
});