commit 0d393033bd8e30f496c21f3d220b9fe036ce7232
parent 0b431ce77c65690f65b7e967bd044f300b32f173
Author: Felicitus <felicitus@felicitus.org>
Date: Fri, 17 Jul 2015 01:22:17 +0200
Re-added footprint delete functionality, removed obsolete code
Diffstat:
4 files changed, 10 insertions(+), 145 deletions(-)
diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/Components/Editor/EditorComponent.js b/src/PartKeepr/FrontendBundle/Resources/public/js/Components/Editor/EditorComponent.js
@@ -89,7 +89,6 @@ Ext.define('PartKeepr.EditorComponent', {
var editor = this.createEditor(this.newItemText);
editor.newItem(defaults);
- console.log(defaults);
this.editorTabPanel.add(editor).show();
},
/**
diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/Components/Footprint/FootprintEditorComponent.js b/src/PartKeepr/FrontendBundle/Resources/public/js/Components/Footprint/FootprintEditorComponent.js
@@ -14,23 +14,5 @@ Ext.define('PartKeepr.FootprintEditorComponent', {
});
this.callParent();
- },
- deleteRecord: function (r) {
- var editor = this.findEditor(r.getId());
-
- if (editor !== null) {
- this.editorTabPanel.remove(editor);
- }
-
- var call = new PartKeepr.ServiceCall("Footprint", "destroy");
- call.setParameter("id", r.get("id"));
- call.setHandler(Ext.bind(function () {
- var oldRecordIndex = PartKeepr.getApplication().getFootprintStore().find("id", r.get("id"));
-
- PartKeepr.getApplication().getFootprintStore().removeAt(oldRecordIndex);
- this.navigation.loadCategories();
- }, this));
-
- call.doCall();
}
});
\ No newline at end of file
diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/Components/Footprint/FootprintNavigation.js b/src/PartKeepr/FrontendBundle/Resources/public/js/Components/Footprint/FootprintNavigation.js
@@ -49,6 +49,11 @@ Ext.define("PartKeepr.FootprintNavigation", {
this.down("partkeepr\\.FootprintTree").on("itemclick", this.onCategoryClick, this);
this.down("partkeepr\\.FootprintGrid").setStore(this.store);
this.down("partkeepr\\.FootprintGrid").on("itemAdd", this.onAddFootprint, this);
+ this.down("partkeepr\\.FootprintGrid").on("itemDelete", function (id)
+ {
+ this.fireEvent("itemDelete", id);
+ }, this
+ );
this.down("partkeepr\\.FootprintGrid").on("itemEdit", function (id)
{
this.fireEvent("itemEdit", id);
@@ -85,6 +90,10 @@ Ext.define("PartKeepr.FootprintNavigation", {
},
syncChanges: function () {
this.down("partkeepr\\.FootprintGrid").getStore().load();
+ },
+ getSelectionModel: function () {
+ "use strict";
+ return this.down("partkeepr\\.FootprintGrid").getSelectionModel();
}
diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/Components/Footprint/FootprintTree.js b/src/PartKeepr/FrontendBundle/Resources/public/js/Components/Footprint/FootprintTree.js
@@ -15,130 +15,5 @@ Ext.define("PartKeepr.FootprintTree", {
/**
* @cfg {String} text The path to the 'delete' icon
*/
- deleteButtonIcon: 'bundles/partkeeprfrontend/images/icons/footprint_delete.png',
-
- /**
- * Initializes the component
- */
- initComponent: function () {
- this.callParent();
-
- /*this.on("itemclick", Ext.bind(function (t,record) {
- if (record.self.getName() == "PartKeepr.Footprint") {
- this.fireEvent("itemEdit", record.get("id"));
- }
- }, this));*/
-
- this.addButton = Ext.create("Ext.button.Button",
- {
- tooltip: i18n("Add Footprint"),
- icon: this.addButtonIcon,
- handler: this._onAddFootprint,
- scope: this
- });
-
- this.deleteButton = Ext.create("Ext.button.Button", {
- tooltip: i18n("Delete Footprint"),
- icon: this.deleteButtonIcon,
- handler: Ext.bind(function () {
- this.fireEvent("itemDelete");
- }, this),
- disabled: true
- });
-
- this.toolbar.add(['-', this.addButton, this.deleteButton]);
-
- this.getSelectionModel().on("select", this._onItemSelect, this);
- this.getSelectionModel().on("deselect", this._onItemDeselect, this);
- },
-
- /**
- * Called when an item was selected
- */
- _onItemSelect: function (selectionModel, record) {
- this._updateDeleteButton(selectionModel, record);
- this.fireEvent("itemSelect", record);
- },
- /**
- * Called when an item was deselected
- */
- _onItemDeselect: function (selectionModel, record) {
- this._updateDeleteButton(selectionModel, record);
- this.fireEvent("itemDeselect", record);
- },
- /**
- * Called when an item was selected. Enables/disables the delete button.
- */
- _updateDeleteButton: function (selectionModel, record) {
- /* Right now, we support delete on a single record only */
- if (this.getSelectionModel().getCount() == 1 && record.self.getName() == "PartKeepr.Footprint") {
- this.deleteButton.enable();
- } else {
- this.deleteButton.disable();
- }
- },
- syncChanges: function (record) {
- var oldRecordIndex = PartKeepr.getApplication().getFootprintStore().find("id", record.get("id"));
-
- if (oldRecordIndex === -1) {
- /* Record doesn't exist yet; add it */
- PartKeepr.getApplication().getFootprintStore().add(record);
- } else {
- var oldRecord = PartKeepr.getApplication().getFootprintStore().getAt(oldRecordIndex);
- oldRecord.set("name", record.get("name"));
- }
-
- this.loadCategories();
- },
- onBeforeDrop: function (node, data, overModel, dropPosition, dropFunction, options) {
- var draggedRecord = data.records[0];
- var droppedOn = this.getView().getRecord(node);
-
- if (droppedOn.self.getName() == "PartKeepr.Footprint") {
- // Target record is a footprint, we don't allow moving categories onto footprints
- return false;
- }
-
- if (draggedRecord.self.getName() == "PartKeepr.Footprint") {
- /* Move Footprint */
- var call = new PartKeepr.ServiceCall("Footprint", "moveFootprint");
-
- call.setParameter("id", draggedRecord.get("id"));
- call.setParameter("targetCategory", droppedOn.get("id"));
- call.setHandler(Ext.bind(function () {
- var sourceNode = this.getRootNode().findChildBy(function () {
- if (this.self.getName() == "PartKeepr.Footprint" && this.get("id") == draggedRecord.get("id")) {
- return true;
- } else {
- return false;
- }
- }, false, true);
-
- var targetNode = this.getRootNode().findChildBy(function () {
- if (this.self.getName() == "PartKeepr.FootprintCategory" && this.get("id") == droppedOn.get("id")) {
- return true;
- } else {
- return false;
- }
- }, false, true);
-
- targetNode.expand();
-
- sourceNode.remove();
-
- targetNode.appendChild(sourceNode);
-
- var oldRecordIndex = PartKeepr.getApplication().getFootprintStore().find("id", draggedRecord.get("id"));
- var oldRecord = PartKeepr.getApplication().getFootprintStore().getAt(oldRecordIndex);
-
- oldRecord.set("category", droppedOn.get("id"));
-
- }, this));
- call.doCall();
-
- return false;
- }
-
- }
-
+ deleteButtonIcon: 'bundles/partkeeprfrontend/images/icons/footprint_delete.png'
});
\ No newline at end of file