Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- MODx.FormPanel.createGoodInTab = function(config) {
- config = config || {};
- // console.log(config);
- this.ident = config.ident || Ext.id();
- Ext.applyIf(config,{
- id: 'good-tab-'+this.ident
- ,border: false
- ,deferredRender: true
- ,baseCls: 'modx-formpanel'
- ,bodyStyle: 'padding: 5px'
- ,url: miniShop.config.connector_url
- ,action: 'mgr/goods/create'
- ,items: [{
- xtype: 'modx-tabs'
- ,id: 'modx-tabs-good-' + Ext.id()
- ,autoHeight: true
- ,forceLayout: false
- ,defaults: {
- border: false,
- autoHeight: true
- }
- ,border: true
- ,hideMode: 'offsets'
- ,stateful: true
- ,stateId: 'ms-tabpanel-good-'+this.ident
- ,stateEvents: ['tabchange']
- ,getState:function() {return { activeTab:this.items.indexOf(this.getActiveTab())};}
- ,items: [{
- id: 'modx-'+this.ident+'-resource'
- ,title: _('resource')
- ,layout: 'fit'
- // ,cls: 'modx-formpanel'
- ,bodyStyle: {
- background: 'transparent',
- padding: '10px'
- }
- ,autoHeight: true
- ,labelAlign: 'top'
- ,labelWidth: 100
- ,items: [{
- layout: 'column'
- ,border: false
- ,items: [{
- columnWidth: .5
- ,border: false
- ,layout: 'form'
- ,items: [{
- xtype: 'textfield',
- name: 'pagetitle',
- id: 'modx-'+this.ident+'-pagetitle',
- fieldLabel: _('pagetitle'),
- anchor: '100%',
- allowBlank: false,
- value: config.record.pagetitle
- }
- ,{
- xtype: 'textfield',
- name: 'longtitle',
- id: 'modx-'+this.ident+'-longtitle',
- fieldLabel: _('long_title'),
- anchor: '100%',
- value: config.record.longtitle
- }
- ,{
- xtype: 'textarea',
- name: 'description',
- id: 'modx-'+this.ident+'-description',
- fieldLabel: _('description'),
- anchor: '100%',
- grow: false,
- height: 50,
- style: 'font-family:Arial',
- value: config.record.description
- }
- ,{
- xtype: 'textarea',
- name: 'introtext',
- id: 'modx-'+this.ident+'-introtext',
- fieldLabel: _('introtext'),
- anchor: '100%',
- height: 50,
- value: config.record.introtext
- }
- ,{
- xtype: 'xcheckbox',
- name: 'deleted',
- id: 'modx-'+this.ident+'-deleted',
- boxLabel: _('deleted'),
- description: _('resource_delete_help'),
- inputValue: 1,
- checked: false
- }
- ,{
- xtype: 'xcheckbox',
- name: 'clearCache',
- id: 'modx-'+this.ident+'-clearcache',
- boxLabel: _('clear_cache_on_save'),
- description: _('clear_cache_on_save_msg'),
- inputValue: 1,
- checked: true,
- value: config.record.clearCache
- }
- ,{
- xtype : 'xcheckbox',
- name : 'richtext',
- value: config.record.richtext,
- id : 'modx-'+this.ident+'-richtext',
- boxLabel : _('resource_richtext'),
- description: _('resource_richtext_help'),
- inputValue : 1,
- checked : config.record.searchable
- }
- ]
- },{
- columnWidth: .5
- ,border: false
- ,layout: 'form'
- ,items: [
- {
- xtype: 'minishop-combo-goodstemplate',
- id: 'modx-'+this.ident+'-template',
- fieldLabel: _('template'),
- editable: false,
- anchor: '100%',
- value: miniShop.config.ms_goods_tpls[0]
- }
- ,{
- xtype: 'minishop-filter-category',
- id: 'modx-'+this.ident+'-category',
- name: 'parent',
- fieldLabel: _('ms.category'),
- baseParams: {
- action: 'mgr/combo/cats_and_goods',
- addall: 0
- },
- anchor: '100%',
- hiddenName: 'parent',
- value: config.record.parent
- }
- ,{
- xtype: 'textfield',
- name: 'alias',id: 'modx-'+this.ident+'-alias',
- fieldLabel: _('alias'),
- anchor: '100%',
- value: config.record.alias
- }
- ,{
- xtype: 'textfield',name: 'menutitle',id: 'modx-'+this.ident+'-menutitle',fieldLabel: _('resource_menutitle'),anchor: '100%',value: config.record.menutitle}
- ,{
- xtype: 'xcheckbox',name: 'published',id: 'modx-'+this.ident+'-published',boxLabel: _('resource_published'),description: _('resource_published_help'),inputValue: 1,checked: config.record.published}
- ,{
- xtype: 'xcheckbox',name: 'hidemenu',id: 'modx-'+this.ident+'-hidemenu',boxLabel: _('resource_hide_from_menus'),description: _('resource_hide_from_menus_help'),inputValue: 1,checked: config.record.hidemenu}
- ,{
- xtype: 'xcheckbox',name: 'searchable',id: 'modx-'+this.ident+'-searchable',boxLabel: _('resource_searchable'),description: _('resource_searchable_help'),inputValue: 1,checked: config.record.searchable}
- ,{
- xtype: 'xcheckbox',
- name: 'cacheable',
- id: 'modx-'+this.ident+'-cacheable',
- boxLabel: _('resource_cacheable'),
- description: _('resource_cacheable_help'),
- inputValue: 1,
- checked: config.record.cacheable
- }
- ]
- }]
- }
- ,{
- xtype: 'hidden',
- name: 'class_key',
- value: 'modDocument'
- }
- ,{xtype: 'hidden',name: 'context_key', value: config.record.context_key}
- ,{xtype: 'hidden',name: 'content_type' ,value: 1}
- ,{xtype: 'hidden',name: 'content_dispo',value: 0}
- ,{xtype: 'hidden',name: 'isfolder' ,value: 0}
- ]
- },
- {
- id: 'modx-'+this.ident+'-descr'
- ,title: 'Описание'
- ,layout: 'fit'
- ,cls: 'modx-panel'
- ,bodyStyle: {
- background: 'transparent',
- padding: '5px'
- }
- ,autoHeight: true
- ,items: [{
- xtype : config.record.richtext ? 'htmleditor' : 'textarea',
- name : 'content',
- id : 'modx-'+this.ident+'-content',
- anchor : '100%',
- style : 'font-family:Arial',
- // maxHeight : '700px',
- overflow: 'auto',
- value: config.record.content
- }]
- },
- {
- id: 'modx-'+this.ident+'-properties'
- ,title: _('ms.properties')
- ,layout: 'form'
- ,cls: 'modx-panel'
- ,autoHeight: true
- ,forceLayout: true
- ,labelAlign: 'left'
- ,labelWidth: 200
- ,defaults: {autoHeight: true ,border: false}
- ,style: 'background: transparent;'
- ,bodyStyle: { background: 'transparent', padding: '10px' }
- ,items: [
- {
- xtype: 'hidden',
- name: 'id',
- value: config.record.id
- }
- ,{
- xtype: 'hidden',
- name: 'wid',
- value: config.record.wid
- }
- ,{
- xtype: 'textfield',
- name: 'article',
- fieldLabel: _('ms.article'),
- value: config.record.article
- }
- ,{
- xtype: 'spinnerfield',
- name: 'price',
- fieldLabel: _('ms.price'),
- minValue: 0,
- maxValue: 1000000,
- allowDecimals: true,
- decimalPrecision: 2,
- incrementValue: 0.01,
- alternateIncrementValue: 10.0,
- accelerate: true,
- value: config.record.price
- }
- ,{
- xtype: 'spinnerfield',
- name: 'weight',
- fieldLabel: _('ms.weight'),
- minValue: 0,
- maxValue: 1000,
- allowDecimals: true,
- decimalPrecision: 3,
- incrementValue: 0.001,
- alternateIncrementValue: 1.0,
- accelerate: true,
- value: config.record.weight
- }
- ,{
- xtype: 'ms-combo-browser',
- openTo: config.record.img,
- name: 'img',
- fieldLabel: _('ms.img'),
- anchor: '100%',
- value: config.record.img
- }
- ,{
- xtype: 'spinnerfield',
- name: 'remains',
- fieldLabel: _('ms.remains'),
- minValue: 0,
- maxValue: 10000,
- allowDecimals: false,
- incrementValue: 1,
- alternateIncrementValue: 100,
- accelerate: true,
- value: config.record.remains
- }
- ,{
- xtype: 'textfield',
- name: 'reserved',
- disabled: true,
- fieldLabel: _('ms.reserved'),
- value: config.record.reserved
- }
- ,{
- xtype: 'ms-superbox-tags',
- name: 'tags[]',
- value: config.record.tags,
- fieldLabel: _('ms.tags')
- }
- ,{
- xtype: 'minishop-combo-brands',
- fieldLabel: _('ms.goods.add1'),
- id: 'minishop-'+this.ident+'-add1',
- name: 'add1',
- anchor: '100%',
- value: config.record.add1
- }
- ,{
- xtype: 'textfield',
- name: 'add2',
- fieldLabel: _('ms.goods.add2'),
- anchor: '100%',
- value: config.record.add2
- }
- ,{
- xtype: 'textfield',
- name: 'add3',
- fieldLabel: _('ms.goods.add3'),
- autoHeight: false,
- anchor: '100%',
- value: config.record.add3
- },{
- xtype: 'checkbox',
- name: 'duplicate',
- value: 1,
- style: 'padding: 10px;',
- fieldLabel: _('ms.goods.duplicate'),
- description: _('ms.goods.duplicate.desc')
- }
- ]
- },
- {
- id: 'modx-'+this.ident+'-params',
- title: _('ms.params'),
- items: [
- {
- xtype: 'minishop-grid-params',
- baseParams: {
- action: 'mgr/goods/params/getlist',
- gid: gid
- },
- gid: gid,
- emptyText: _('ms.params.select')
- }
- ]
- },
- {
- id: 'modx-'+this.ident+'-gallery'
- ,title: 'Фотографии'
- ,items: [{
- xtype: 'minishop-grid-gallery',
- baseParams: {
- action: 'mgr/goods/gallery/getlist',
- gid: gid
- },
- gid: gid
- }]
- }]
- }],
- buttons: [{
- text: config.saveBtnText || _('save_and_close'),
- scope: this,
- /* handler: function() {
- changed = 1;
- this.saveGoodsInTab
- }*/
- handler: this.saveGoodsInTab
- },{
- text: _('close'),
- scope: this,
- handler: this.closeGoodTab
- // function() {
- // Ext.getCmp('minishop-good-tab'+this.ident).remove();
- // console.log(this.ownerCt);
- // ct = this;
- // this.ownerCt.remove();
- // }
- }]
- });
- MODx.FormPanel.createGoodInTab.superclass.constructor.call(this,config);
- };
- Ext.extend(MODx.FormPanel.createGoodInTab,MODx.FormPanel,{
- closeGoodTab: function(){
- // console.log(this);
- Ext.getCmp('minishop-tabs-main').remove(this.id);
- },
- saveGoodsInTab: function(){
- console.log(Ext.encode(this.getForm().getFieldValues()));
- var postData = {
- formData: Ext.encode(this.getForm().getFieldValues()),
- action: 'mgr/hotels/saveHotel'
- }
- }
- });
- Ext.reg('minishop-panel-creategoodintab',MODx.FormPanel.createGoodInTab);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement