commit 3e3781d6a5753bdc4093074efe426e3d139339fd
parent 98d60570253feed47fba294c80cb7d0d3265318d
Author: Felicitus <felicitus@felicitus.org>
Date: Tue, 5 Jul 2011 03:59:49 +0200
Fix for issue #78
Diffstat:
4 files changed, 34 insertions(+), 17 deletions(-)
diff --git a/frontend/js/Components/Editor/Editor.js b/frontend/js/Components/Editor/Editor.js
@@ -41,15 +41,16 @@ Ext.define('PartKeepr.Editor', {
handler: Ext.bind(this.onCancelEdit, this)
});
+ this.bottomToolbar = Ext.create("Ext.toolbar.Toolbar", {
+ enableOverflow: true,
+ margin: '10px',
+ dock: 'bottom',
+ ui: 'footer',
+ items: [ this.saveButton, this.cancelButton ]
+ });
+
Ext.apply(this, {
- dockedItems: [{
- xtype: 'toolbar',
- enableOverflow: true,
- margin: '10px',
- dock: 'bottom',
- ui: 'footer',
- items: [ this.saveButton, this.cancelButton ]
- }]});
+ dockedItems: [ this.bottomToolbar ]});
this.on("dirtychange", function (form, dirty) {
// @todo Check dirty flag
@@ -97,9 +98,11 @@ Ext.define('PartKeepr.Editor', {
scope: this
});
},
- _onSave: function (record) {
- this.record = record;
- this.fireEvent("itemSaved", this.record);
+ _onSave: function (record, response) {
+ if (response.success == true) {
+ this.record = record;
+ this.fireEvent("itemSaved", this.record);
+ }
},
_setTitle: function (title) {
this.setTitle(title);
diff --git a/frontend/js/Components/Part/Editor/PartEditor.js b/frontend/js/Components/Part/Editor/PartEditor.js
@@ -18,6 +18,9 @@ Ext.define('PartKeepr.PartEditor', {
* Initializes the editor fields
*/
initComponent: function () {
+ this.keepOpenCheckbox = Ext.create("Ext.form.field.Checkbox", {
+ boxLabel: i18n("Create blank item after save")
+ });
// Defines the basic editor fields
var basicEditorFields = [{
@@ -185,13 +188,23 @@ Ext.define('PartKeepr.PartEditor', {
this.addEvents("partSaved", "titleChange");
this.callParent();
+
+ if (this.partMode == "create") {
+ this.bottomToolbar.add(this.keepOpenCheckbox);
+ }
},
onEditStart: function () {
this.bindChildStores();
},
_onItemSaved: function () {
this.fireEvent("partSaved", this.record);
- this.bindChildStores();
+
+ if (this.keepOpenCheckbox.getValue() !== true) {
+ this.fireEvent("editorClose");
+ } else {
+ var newItem = Ext.create("PartKeepr.Part", this.partDefaults);
+ this.editItem(newItem);
+ }
},
bindChildStores: function () {
this.partDistributorGrid.bindStore(this.record.distributors());
diff --git a/frontend/js/Components/Part/Editor/PartEditorWindow.js b/frontend/js/Components/Part/Editor/PartEditorWindow.js
@@ -37,14 +37,12 @@ Ext.define('PartKeepr.PartEditorWindow', {
}
this.items = [ this.editor ];
-
- this.editor.on("editorClose", function () { this.close(); }, this);
-
+
/**
- * We need a delay, since if others are listening for "partSaved", the dialog plus the record could be destroyed
+ * We need a delay, since if others are listening for "editorClose", the dialog plus the record could be destroyed
* before any following listeners have a chance to receive the record, resulting in strange problems.
*/
- this.editor.on("partSaved", function (record) { this.close();}, this, { delay: 200 });
+ this.editor.on("editorClose", function (record) { this.close();}, this, { delay: 200 });
this.editor.on("titleChange", function (val) { this.setTitle(val); }, this);
this.callParent();
diff --git a/frontend/js/Components/Part/PartsManager.js b/frontend/js/Components/Part/PartsManager.js
@@ -142,6 +142,9 @@ Ext.define('PartKeepr.PartManager', {
record = Ext.create("PartKeepr.Part", defaults);
+ // Inject the defaults to the editor, so the editor can create a new item on its own
+ j.editor.partDefaults = defaults;
+
j.editor.editItem(record);
j.show();
},