commit 972c60c18040cdb6e547fd457dfe3635dbb20a8b
parent 5b54461ec8e82e967e048481be1a45fc6fa8aae8
Author: Felicitus <felicitus@felicitus.org>
Date: Wed, 18 Jul 2012 04:22:18 +0200
Added compact layout user setting, fixes #185
Diffstat:
5 files changed, 105 insertions(+), 45 deletions(-)
diff --git a/src/frontend/js/Components/Part/PartsManager.js b/src/frontend/js/Components/Part/PartsManager.js
@@ -20,7 +20,7 @@ Ext.define('PartKeepr.PartManager', {
*
* @var boolean True if compact layout should be used, false otherwise.
*/
- compactLayout: true,
+ compactLayout: false,
initComponent: function () {
@@ -152,8 +152,6 @@ Ext.define('PartKeepr.PartManager', {
}, this.detailPanel ];
}
-
-
this.callParent();
},
/**
diff --git a/src/frontend/js/Components/User/Preferences/CategoryTreePreferences.js b/src/frontend/js/Components/User/Preferences/CategoryTreePreferences.js
@@ -1,28 +0,0 @@
-Ext.define('PartKeepr.CategoryTreePreferencesPanel', {
- extend: 'Ext.form.FormPanel',
- title: i18n("Category Tree"),
- bodyStyle: 'background:#DBDBDB;padding: 10px;',
- initComponent: function () {
- this.showDescriptionsCheckbox = Ext.create("Ext.form.field.Checkbox", {
- boxLabel: i18n("Show category descriptions"),
- handler: Ext.bind(this.showDescriptionsHandler, this)
- });
-
- if (PartKeepr.getApplication().getUserPreference("partkeepr.categorytree.showdescriptions") === false) {
- this.showDescriptionsCheckbox.setValue(false);
- } else {
- this.showDescriptionsCheckbox.setValue(true);
- }
-
- this.items = [ this.showDescriptionsCheckbox ];
-
- this.callParent();
- },
- /**
- * Handler when the "show descriptions" checkbox is clicked.
- */
- showDescriptionsHandler: function (checkbox, checked) {
- PartKeepr.getApplication().setUserPreference("partkeepr.categorytree.showdescriptions", checked);
- }
-});
-
diff --git a/src/frontend/js/Components/User/Preferences/DisplayPreferencesPanel.js b/src/frontend/js/Components/User/Preferences/DisplayPreferencesPanel.js
@@ -0,0 +1,72 @@
+Ext.define('PartKeepr.DisplayPreferencesPanel', {
+ extend: 'Ext.form.FormPanel',
+ title: i18n("Display"),
+ bodyStyle: 'background:#DBDBDB;padding: 10px;',
+ initComponent: function () {
+ this.showDescriptionsCheckbox = Ext.create("Ext.form.field.Checkbox", {
+ boxLabel: i18n("Show category descriptions"),
+ handler: Ext.bind(this.showDescriptionsHandler, this)
+ });
+
+ if (PartKeepr.getApplication().getUserPreference("partkeepr.categorytree.showdescriptions") === false) {
+ this.showDescriptionsCheckbox.setValue(false);
+ } else {
+ this.showDescriptionsCheckbox.setValue(true);
+ }
+
+ this.compactLayout = Ext.create("Ext.form.field.Radio", {
+ boxLabel: i18n("Compact Layout") + '<br/> <img style="margin-top: 2px; margin-left: 18px;" src="resources/images/layout-compact.png"/>',
+ name: 'rb',
+ inputValue: 'compact'
+ });
+
+ this.standardLayout = Ext.create("Ext.form.field.Radio", {
+ boxLabel: i18n("Standard Layout") + '<br/> <img style="margin-top: 2px; margin-left: 18px;" src="resources/images/layout-standard.png"/>',
+ name: 'rb',
+ inputValue: 'standard'
+ });
+
+ if (PartKeepr.getApplication().getUserPreference("partkeepr.partmanager.compactlayout", false) === true) {
+ this.compactLayout.setValue(true);
+ } else {
+ this.standardLayout.setValue(true);
+ }
+ this.compactLayoutChooser = Ext.create("Ext.form.RadioGroup", {
+ fieldLabel: i18n("Part Manager Layout"),
+ labelWidth: 120,
+ columns: 2,
+ width: 400,
+ vertical: true,
+ listeners: {
+ change: function (field, newValue) {
+ if (newValue.rb == "standard") {
+ value = false;
+ } else {
+ value = true;
+ }
+
+ PartKeepr.getApplication().setUserPreference("partkeepr.partmanager.compactlayout", value);
+ PartKeepr.getApplication().recreatePartManager();
+ }
+ },
+ items: [
+ this.compactLayout,
+ this.standardLayout
+ ]
+ });
+
+ this.items = [ this.showDescriptionsCheckbox, this.compactLayoutChooser ];
+
+ this.callParent();
+ },
+ /**
+ * Handler when the "show descriptions" checkbox is clicked.
+ */
+ showDescriptionsHandler: function (checkbox, checked) {
+ PartKeepr.getApplication().setUserPreference("partkeepr.categorytree.showdescriptions", checked);
+ },
+ compactLayoutHandler: function () {
+ //PartKeepr.getApplication().setUserPreference("partkeepr.partmanager.compactlayout", checked);
+ }
+});
+
diff --git a/src/frontend/js/Components/User/UserPreferences.js b/src/frontend/js/Components/User/UserPreferences.js
@@ -8,9 +8,9 @@ Ext.define('PartKeepr.UserPreferencePanel', {
this.passwordChangePanel = Ext.create("PartKeepr.UserPasswordChangePanel");
this.tipsPanel = Ext.create("PartKeepr.TipOfTheDayPreferencesPanel");
this.formattingPanel = Ext.create("PartKeepr.FormattingPreferencesPanel");
- this.categoryTreePanel = Ext.create("PartKeepr.CategoryTreePreferencesPanel");
+ this.displayPreferencesPanel = Ext.create("PartKeepr.DisplayPreferencesPanel");
this.stockPanel = Ext.create("PartKeepr.StockPreferencesPanel");
- this.items = [ this.tipsPanel, this.formattingPanel, this.categoryTreePanel, this.passwordChangePanel, this.stockPanel ];
+ this.items = [ this.tipsPanel, this.formattingPanel, this.displayPreferencesPanel, this.passwordChangePanel, this.stockPanel ];
this.callParent();
}
});
diff --git a/src/frontend/js/PartKeepr.js b/src/frontend/js/PartKeepr.js
@@ -1,9 +1,5 @@
Ext.namespace('PartKeepr');
-Ext.Loader.setPath({
- 'PartKeepr': 'js'
-});
-
PartKeepr.application = null;
Ext.application({
@@ -65,14 +61,9 @@ Ext.application({
}
this.reloadStores();
-
- this.partManager = Ext.create("PartKeepr.PartManager", {
- title: i18n("Part Manager"),
- iconCls: 'icon-brick',
- closable: false
- });
-
- this.addItem(this.partManager);
+
+ this.createPartManager();
+
this.menuBar.enable();
this.doSystemStatusCheck();
@@ -89,6 +80,33 @@ Ext.application({
},
/**
+ * Re-creates the part manager. This is usually called when the "compactLayout" configuration option has been
+ * changed.
+ *
+ * @param none
+ * @return nothing
+ */
+ recreatePartManager: function () {
+ this.centerPanel.remove(this.partManager);
+ this.getPartManager().destroy();
+
+ this.createPartManager();
+ },
+ /**
+ * Creates the part manager. While this is usually only done after login, it can also happen when the user changes
+ * the "compact" preference.
+ */
+ createPartManager: function () {
+ this.partManager = Ext.create("PartKeepr.PartManager", {
+ title: i18n("Part Manager"),
+ compactLayout: PartKeepr.getApplication().getUserPreference("partkeepr.partmanager.compactlayout", false),
+ iconCls: 'icon-brick',
+ closable: false
+ });
+
+ this.centerPanel.insert(0, this.partManager);
+ },
+ /**
* Sets the initial user preferences, which are applied into the userPreferenceStore after login.
*/
setInitialUserPreferences: function (obj) {