Advertisement
vanchelo

Untitled

Sep 10th, 2012
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. MODx.FormPanel.createGoodInTab = function(config) {
  2.     config = config || {};
  3.     // console.log(config);
  4.     this.ident = config.ident || Ext.id();
  5.     Ext.applyIf(config,{
  6.         id: 'good-tab-'+this.ident
  7.         ,border: false
  8.         ,deferredRender: true
  9.         ,baseCls: 'modx-formpanel'
  10.         ,bodyStyle: 'padding: 5px'
  11.         ,url: miniShop.config.connector_url
  12.         ,action: 'mgr/goods/create'
  13.         ,items: [{
  14.             xtype: 'modx-tabs'
  15.             ,id: 'modx-tabs-good-' + Ext.id()
  16.             ,autoHeight: true
  17.             ,forceLayout: false
  18.             ,defaults: {
  19.                 border: false,
  20.                 autoHeight: true
  21.             }
  22.             ,border: true
  23.             ,hideMode: 'offsets'
  24.             ,stateful: true
  25.             ,stateId: 'ms-tabpanel-good-'+this.ident
  26.             ,stateEvents: ['tabchange']
  27.             ,getState:function() {return { activeTab:this.items.indexOf(this.getActiveTab())};}
  28.             ,items: [{
  29.                 id: 'modx-'+this.ident+'-resource'
  30.                 ,title: _('resource')
  31.                 ,layout: 'fit'
  32.                 // ,cls: 'modx-formpanel'
  33.                 ,bodyStyle: {
  34.                     background: 'transparent',
  35.                     padding: '10px'
  36.                 }
  37.                 ,autoHeight: true
  38.                 ,labelAlign: 'top'
  39.                 ,labelWidth: 100
  40.                 ,items: [{
  41.                     layout: 'column'
  42.                     ,border: false
  43.                     ,items: [{
  44.                         columnWidth: .5
  45.                         ,border: false
  46.                         ,layout: 'form'
  47.                         ,items: [{
  48.                                 xtype: 'textfield',
  49.                                 name: 'pagetitle',
  50.                                 id: 'modx-'+this.ident+'-pagetitle',
  51.                                 fieldLabel: _('pagetitle'),
  52.                                 anchor: '100%',
  53.                                 allowBlank: false,
  54.                                 value: config.record.pagetitle
  55.                             }
  56.                             ,{
  57.                                 xtype: 'textfield',
  58.                                 name: 'longtitle',
  59.                                 id: 'modx-'+this.ident+'-longtitle',
  60.                                 fieldLabel: _('long_title'),
  61.                                 anchor: '100%',
  62.                                 value: config.record.longtitle
  63.                             }
  64.                             ,{
  65.                                 xtype: 'textarea',
  66.                                 name: 'description',
  67.                                 id: 'modx-'+this.ident+'-description',
  68.                                 fieldLabel: _('description'),
  69.                                 anchor: '100%',
  70.                                 grow: false,
  71.                                 height: 50,
  72.                                 style: 'font-family:Arial',
  73.                                 value: config.record.description
  74.                             }
  75.                             ,{
  76.                                 xtype: 'textarea',
  77.                                 name: 'introtext',
  78.                                 id: 'modx-'+this.ident+'-introtext',
  79.                                 fieldLabel: _('introtext'),
  80.                                 anchor: '100%',
  81.                                 height: 50,
  82.                                 value: config.record.introtext
  83.                             }
  84.                             ,{
  85.                                 xtype: 'xcheckbox',
  86.                                 name: 'deleted',
  87.                                 id: 'modx-'+this.ident+'-deleted',
  88.                                 boxLabel: _('deleted'),
  89.                                 description: _('resource_delete_help'),
  90.                                 inputValue: 1,
  91.                                 checked: false
  92.                             }
  93.                             ,{
  94.                                 xtype: 'xcheckbox',
  95.                                 name: 'clearCache',
  96.                                 id: 'modx-'+this.ident+'-clearcache',
  97.                                 boxLabel: _('clear_cache_on_save'),
  98.                                 description: _('clear_cache_on_save_msg'),
  99.                                 inputValue: 1,
  100.                                 checked: true,
  101.                                 value: config.record.clearCache
  102.                             }
  103.                             ,{
  104.                                 xtype      : 'xcheckbox',
  105.                                 name       : 'richtext',
  106.                                 value: config.record.richtext,
  107.                                 id         : 'modx-'+this.ident+'-richtext',
  108.                                 boxLabel   : _('resource_richtext'),
  109.                                 description: _('resource_richtext_help'),
  110.                                 inputValue : 1,
  111.                                 checked    : config.record.searchable
  112.                             }
  113.                         ]
  114.                     },{
  115.                         columnWidth: .5
  116.                         ,border: false
  117.                         ,layout: 'form'
  118.                         ,items: [
  119.                             {
  120.                                 xtype: 'minishop-combo-goodstemplate',
  121.                                 id: 'modx-'+this.ident+'-template',
  122.                                 fieldLabel: _('template'),
  123.                                 editable: false,
  124.                                 anchor: '100%',
  125.                                 value: miniShop.config.ms_goods_tpls[0]
  126.                             }
  127.                             ,{
  128.                                 xtype: 'minishop-filter-category',
  129.                                 id: 'modx-'+this.ident+'-category',
  130.                                 name: 'parent',
  131.                                 fieldLabel: _('ms.category'),
  132.                                 baseParams: {
  133.                                     action: 'mgr/combo/cats_and_goods',
  134.                                     addall: 0
  135.                                 },
  136.                                 anchor: '100%',
  137.                                 hiddenName: 'parent',
  138.                                 value: config.record.parent
  139.                             }
  140.                             ,{
  141.                                 xtype: 'textfield',
  142.                                 name: 'alias',id: 'modx-'+this.ident+'-alias',
  143.                                 fieldLabel: _('alias'),
  144.                                 anchor: '100%',
  145.                                 value: config.record.alias
  146.                             }
  147.                             ,{
  148.                                 xtype: 'textfield',name: 'menutitle',id: 'modx-'+this.ident+'-menutitle',fieldLabel: _('resource_menutitle'),anchor: '100%',value: config.record.menutitle}
  149.                             ,{
  150.                                 xtype: 'xcheckbox',name: 'published',id: 'modx-'+this.ident+'-published',boxLabel: _('resource_published'),description: _('resource_published_help'),inputValue: 1,checked: config.record.published}
  151.                             ,{
  152.                                 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}
  153.                             ,{
  154.                                 xtype: 'xcheckbox',name: 'searchable',id: 'modx-'+this.ident+'-searchable',boxLabel: _('resource_searchable'),description: _('resource_searchable_help'),inputValue: 1,checked: config.record.searchable}
  155.                             ,{
  156.                                 xtype: 'xcheckbox',
  157.                                 name: 'cacheable',
  158.                                 id: 'modx-'+this.ident+'-cacheable',
  159.                                 boxLabel: _('resource_cacheable'),
  160.                                 description: _('resource_cacheable_help'),
  161.                                 inputValue: 1,
  162.                                 checked: config.record.cacheable
  163.                             }
  164.                         ]
  165.                     }]
  166.                 }
  167.                 ,{
  168.                     xtype: 'hidden',
  169.                     name: 'class_key',
  170.                     value: 'modDocument'
  171.                 }
  172.                 ,{xtype: 'hidden',name: 'context_key', value: config.record.context_key}
  173.                 ,{xtype: 'hidden',name: 'content_type' ,value: 1}
  174.                 ,{xtype: 'hidden',name: 'content_dispo',value: 0}
  175.                 ,{xtype: 'hidden',name: 'isfolder' ,value: 0}
  176.                 ]
  177.             },
  178.             {
  179.                 id: 'modx-'+this.ident+'-descr'
  180.                 ,title: 'Описание'
  181.                 ,layout: 'fit'
  182.                 ,cls: 'modx-panel'
  183.                 ,bodyStyle: {
  184.                     background: 'transparent',
  185.                     padding: '5px'
  186.                 }
  187.                 ,autoHeight: true
  188.                 ,items: [{
  189.                     xtype     : config.record.richtext ? 'htmleditor' : 'textarea',
  190.                     name      : 'content',
  191.                     id        : 'modx-'+this.ident+'-content',
  192.                     anchor    : '100%',
  193.                     style     : 'font-family:Arial',
  194.                     // maxHeight    : '700px',
  195.                     overflow: 'auto',
  196.                     value: config.record.content
  197.                 }]
  198.             },
  199.             {
  200.                 id: 'modx-'+this.ident+'-properties'
  201.                 ,title: _('ms.properties')
  202.                 ,layout: 'form'
  203.                 ,cls: 'modx-panel'
  204.                 ,autoHeight: true
  205.                 ,forceLayout: true
  206.                 ,labelAlign: 'left'
  207.                 ,labelWidth: 200
  208.                 ,defaults: {autoHeight: true ,border: false}
  209.                 ,style: 'background: transparent;'
  210.                 ,bodyStyle: { background: 'transparent', padding: '10px' }
  211.                 ,items: [
  212.                     {
  213.                         xtype: 'hidden',
  214.                         name: 'id',
  215.                         value: config.record.id
  216.                     }
  217.                     ,{
  218.                         xtype: 'hidden',
  219.                         name: 'wid',
  220.                         value: config.record.wid
  221.                     }
  222.                     ,{
  223.                         xtype: 'textfield',
  224.                         name: 'article',
  225.                         fieldLabel: _('ms.article'),
  226.                         value: config.record.article
  227.                     }
  228.                     ,{
  229.                         xtype: 'spinnerfield',
  230.                         name: 'price',
  231.                         fieldLabel: _('ms.price'),
  232.                         minValue: 0,
  233.                         maxValue: 1000000,
  234.                         allowDecimals: true,
  235.                         decimalPrecision: 2,
  236.                         incrementValue: 0.01,
  237.                         alternateIncrementValue: 10.0,
  238.                         accelerate: true,
  239.                         value: config.record.price
  240.                     }
  241.                     ,{
  242.                         xtype: 'spinnerfield',
  243.                         name: 'weight',
  244.                         fieldLabel: _('ms.weight'),
  245.                         minValue: 0,
  246.                         maxValue: 1000,
  247.                         allowDecimals: true,
  248.                         decimalPrecision: 3,
  249.                         incrementValue: 0.001,
  250.                         alternateIncrementValue: 1.0,
  251.                         accelerate: true,
  252.                         value: config.record.weight
  253.                     }
  254.                     ,{
  255.                         xtype: 'ms-combo-browser',
  256.                         openTo: config.record.img,
  257.                         name: 'img',
  258.                         fieldLabel: _('ms.img'),
  259.                         anchor: '100%',
  260.                         value: config.record.img
  261.                     }
  262.                     ,{
  263.                         xtype: 'spinnerfield',
  264.                         name: 'remains',
  265.                         fieldLabel: _('ms.remains'),
  266.                         minValue: 0,
  267.                         maxValue: 10000,
  268.                         allowDecimals: false,
  269.                         incrementValue: 1,
  270.                         alternateIncrementValue: 100,
  271.                         accelerate: true,
  272.                         value: config.record.remains
  273.                     }
  274.                     ,{
  275.                         xtype: 'textfield',
  276.                         name: 'reserved',
  277.                         disabled: true,
  278.                         fieldLabel: _('ms.reserved'),
  279.                         value: config.record.reserved
  280.  
  281.                     }
  282.                     ,{
  283.                         xtype: 'ms-superbox-tags',
  284.                         name: 'tags[]',
  285.                         value: config.record.tags,
  286.                         fieldLabel: _('ms.tags')
  287.                     }
  288.                     ,{
  289.                         xtype: 'minishop-combo-brands',
  290.                         fieldLabel: _('ms.goods.add1'),
  291.                         id: 'minishop-'+this.ident+'-add1',
  292.                         name: 'add1',
  293.                         anchor: '100%',
  294.                         value: config.record.add1
  295.                     }
  296.                     ,{
  297.                         xtype: 'textfield',
  298.                         name: 'add2',
  299.                         fieldLabel: _('ms.goods.add2'),
  300.                         anchor: '100%',
  301.                         value: config.record.add2
  302.                     }
  303.                     ,{
  304.                         xtype: 'textfield',
  305.                         name: 'add3',
  306.                         fieldLabel: _('ms.goods.add3'),
  307.                         autoHeight: false,
  308.                         anchor: '100%',
  309.                         value: config.record.add3
  310.                     },{
  311.                         xtype: 'checkbox',
  312.                         name: 'duplicate',
  313.                         value: 1,
  314.                         style: 'padding: 10px;',
  315.                         fieldLabel: _('ms.goods.duplicate'),
  316.                         description: _('ms.goods.duplicate.desc')
  317.                     }
  318.                 ]
  319.             },
  320.             {
  321.                 id: 'modx-'+this.ident+'-params',
  322.                 title: _('ms.params'),
  323.                 items: [
  324.                     {
  325.                         xtype: 'minishop-grid-params',
  326.                         baseParams: {
  327.                             action: 'mgr/goods/params/getlist',
  328.                             gid: gid
  329.                         },
  330.                         gid: gid,
  331.                         emptyText: _('ms.params.select')
  332.  
  333.                     }
  334.                 ]
  335.             },
  336.             {
  337.                 id: 'modx-'+this.ident+'-gallery'
  338.                 ,title: 'Фотографии'
  339.                 ,items: [{
  340.                     xtype: 'minishop-grid-gallery',
  341.                     baseParams: {
  342.                         action: 'mgr/goods/gallery/getlist',
  343.                         gid: gid
  344.                     },
  345.                     gid: gid
  346.                 }]
  347.             }]
  348.         }],
  349.         buttons: [{
  350.             text: config.saveBtnText || _('save_and_close'),
  351.             scope: this,
  352. /*            handler: function() {
  353.                 changed = 1;
  354.                 this.saveGoodsInTab
  355.             }*/
  356.             handler: this.saveGoodsInTab
  357.         },{
  358.             text: _('close'),
  359.             scope: this,
  360.             handler: this.closeGoodTab
  361.                 // function() {
  362.                 // Ext.getCmp('minishop-good-tab'+this.ident).remove();
  363.                 // console.log(this.ownerCt);
  364.                 // ct = this;
  365.                 // this.ownerCt.remove();
  366.  
  367.             // }
  368.         }]
  369.     });
  370.     MODx.FormPanel.createGoodInTab.superclass.constructor.call(this,config);
  371. };
  372. Ext.extend(MODx.FormPanel.createGoodInTab,MODx.FormPanel,{
  373.     closeGoodTab: function(){
  374.         // console.log(this);
  375.         Ext.getCmp('minishop-tabs-main').remove(this.id);
  376.     },
  377.     saveGoodsInTab: function(){
  378.         console.log(Ext.encode(this.getForm().getFieldValues()));
  379.         var postData = {
  380.             formData: Ext.encode(this.getForm().getFieldValues()),
  381.             action: 'mgr/hotels/saveHotel'
  382.         }
  383.      }
  384. });
  385. Ext.reg('minishop-panel-creategoodintab',MODx.FormPanel.createGoodInTab);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement