public/javascripts/erp_app/desktop/applications/knitkit/west_region/helpers/menu.js in knitkit-2.1.15 vs public/javascripts/erp_app/desktop/applications/knitkit/west_region/helpers/menu.js in knitkit-3.0.0
- old
+ new
@@ -1,53 +1,55 @@
Compass.ErpApp.Desktop.Applications.Knitkit.addMenuOptions = function (self, items, record) {
+ var websiteId = compassDesktop.getModule('knitkit-win').currentWebsite.id;
+
if (record.data['canAddMenuItems']) {
- if (currentUser.hasCapability('create','WebsiteNavItem')) {
+ if (currentUser.hasCapability('create', 'WebsiteNavItem')) {
+
items.push({
- text:'Add Menu Item',
- iconCls:'icon-add',
- handler:function (btn) {
- var addMenuItemWindow = Ext.create("Ext.window.Window", {
- layout:'fit',
- width:375,
- title:'New Menu Item',
- height:175,
- plain:true,
- buttonAlign:'center',
- items:Ext.create('Ext.form.Panel', {
- labelWidth:50,
- frame:false,
- bodyStyle:'padding:5px 5px 0',
- url:'/knitkit/erp_app/desktop/website_nav/add_menu_item',
- defaults:{
- width:225
+ text: 'Add Menu Item',
+ iconCls: 'icon-add',
+ handler: function (btn) {
+ Ext.create("Ext.window.Window", {
+ title: 'New Menu Item',
+ modal: true,
+ buttonAlign: 'center',
+ items: Ext.create('Ext.form.Panel', {
+ labelWidth: 50,
+ frame: false,
+ bodyStyle: 'padding:5px 5px 0',
+ url: '/knitkit/erp_app/desktop/website_nav_item',
+ defaults: {
+ width: 375
},
- items:[
+ items: [
{
- xtype:'textfield',
- fieldLabel:'Title',
- allowBlank:false,
- name:'title'
+ xtype: 'textfield',
+ fieldLabel: 'Title',
+ width: 320,
+ allowBlank: false,
+ name: 'title'
},
{
- xtype:'combo',
- fieldLabel:'Link to',
- name:'link_to',
- id:'knitkit_nav_item_link_to',
- allowBlank:false,
- forceSelection:true,
- editable:false,
- autoSelect:true,
- typeAhead:false,
- mode:'local',
- triggerAction:'all',
- store:[
+ xtype: 'combo',
+ fieldLabel: 'Link to',
+ width: 320,
+ name: 'link_to',
+ id: 'knitkit_nav_item_link_to',
+ allowBlank: false,
+ forceSelection: true,
+ editable: false,
+ autoSelect: true,
+ typeAhead: false,
+ mode: 'local',
+ triggerAction: 'all',
+ store: [
['website_section', 'Section'],
['url', 'Url']
],
- value:'website_section',
- listeners:{
- 'change':function (combo, newValue, oldValue) {
+ value: 'website_section',
+ listeners: {
+ 'change': function (combo, newValue, oldValue) {
switch (newValue) {
case 'website_section':
Ext.getCmp('knitkit_create_website_nav_item_section').show();
Ext.getCmp('knitkit_create_website_nav_item_url').hide();
break;
@@ -58,91 +60,89 @@
}
}
}
},
{
- xtype:'combo',
- id:'knitkit_create_website_nav_item_section',
- hiddenName:'website_section_id',
- name:'website_section_id',
- width:300,
- loadingText:'Retrieving Sections...',
- store:Ext.create("Ext.data.Store", {
- proxy:{
- type:'ajax',
- url:'/knitkit/erp_app/desktop/section/existing_sections',
- reader:{
- type:'json'
+ xtype: 'combo',
+ id: 'knitkit_create_website_nav_item_section',
+ hiddenName: 'website_section_id',
+ name: 'website_section_id',
+ width: 320,
+ loadingText: 'Retrieving Sections...',
+ store: Ext.create("Ext.data.Store", {
+ proxy: {
+ type: 'ajax',
+ url: '/knitkit/erp_app/desktop/section/existing_sections',
+ reader: {
+ type: 'json'
},
- extraParams:{
- website_id:record.data.websiteId
+ extraParams: {
+ website_id: websiteId
}
},
- autoLoad:true,
- fields:[
+ autoLoad: true,
+ fields: [
{
- name:'id'
+ name: 'id'
},
{
- name:'title_permalink'
+ name: 'title_permalink'
}
]
}),
- forceSelection:true,
- editable:false,
- fieldLabel:'Section',
- autoSelect:true,
- typeAhead:false,
- mode:'local',
- displayField:'title_permalink',
- valueField:'id',
-
- triggerAction:'all'
+ forceSelection: true,
+ editable: false,
+ fieldLabel: 'Section',
+ autoSelect: true,
+ typeAhead: false,
+ mode: 'local',
+ displayField: 'title_permalink',
+ valueField: 'id',
+ triggerAction: 'all'
},
{
- xtype:'textfield',
- fieldLabel:'Url',
- id:'knitkit_create_website_nav_item_url',
- hidden:true,
- name:'url'
+ xtype: 'textfield',
+ fieldLabel: 'Url',
+ id: 'knitkit_create_website_nav_item_url',
+ hidden: true,
+ name: 'url'
},
{
- xtype:'hidden',
- name:'klass',
- value:((record.data['websiteNavId']) ? 'WebsiteNav' : 'WebsiteNavItem')
+ xtype: 'hidden',
+ name: 'klass',
+ value: ((record.data['isWebsiteNav']) ? 'WebsiteNav' : 'WebsiteNavItem')
},
{
- xtype:'hidden',
- name:'id',
- value:record.data['websiteNavId'] || record.data['websiteNavItemId']
+ xtype: 'hidden',
+ name: 'parent_id',
+ value: ((record.data['isWebsiteNav']) ? record.data['websiteNavId'] : record.data['websiteNavItemId'])
}
]
}),
- buttons:[
+ buttons: [
{
- text:'Submit',
- listeners:{
- 'click':function (button) {
+ text: 'Submit',
+ listeners: {
+ 'click': function (button) {
var window = button.findParentByType('window'),
- formPanel = window.query('form')[0];
- self.setWindowStatus('Creating menu item...');
+ formPanel = window.query('form')[0];
+
formPanel.getForm().submit({
- reset:true,
- success:function (form, action) {
- self.clearWindowStatus();
+ waitMsg: 'Please wait...',
+ success: function (form, action) {
var obj = Ext.decode(action.response.responseText);
if (obj.success) {
record.appendChild(obj.node);
+ record.expand();
+ window.close();
}
else {
Ext.Msg.alert("Error", obj.msg);
}
- window.close();
},
- failure:function (form, action) {
- self.clearWindowStatus();
+ failure: function (form, action) {
if (action.response === null) {
Ext.Msg.alert("Error", 'Could not create menu item');
}
else {
var obj = Ext.decode(action.response.responseText);
@@ -153,17 +153,16 @@
});
}
}
},
{
- text:'Close',
- handler:function () {
- addMenuItemWindow.close();
+ text: 'Close',
+ handler: function (btn) {
+ btn.up('window').close();
}
}
]
- });
- addMenuItemWindow.show();
+ }).show();
}
});
}
}
\ No newline at end of file