Advertisement
vanchelo

Untitled

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