FR.editFieldSet={getFieldsSelector:function(){this.tree={};this.tree.panel=new Ext.tree.TreePanel({cls:"plain-list fr-user-list",style:"margin-left:120px;border:1px solid var(--sBCol)",animate:true,containerScroll:true,rootVisible:false,autoScroll:true,height:250,width:300,bbar:{style:"padding:5px",items:[{text:"Add",iconCls:"fa-plus",ref:"../addBtn",style:"margin-right:10px",handler:function(){Ext.getCmp("gridTabPanel").el.mask("Loading...");FR.tempPanel.load({url:FR.URLRoot+FR.modules.metadata_fields.url.add,params:{sid:FR.setInfo.id},scripts:true,callback:function(){Ext.getCmp("gridTabPanel").el.unmask()}})},scope:this},{text:"Edit",ref:"../editBtn",iconCls:"fa-pen",style:"margin-right:10px",disabled:true,handler:function(){var node=this.tree.panel.getSelectionModel().getSelectedNode();Ext.getCmp("gridTabPanel").el.mask("Loading...");FR.tempPanel.load({url:FR.URLRoot+FR.modules.metadata_fields.url.edit,params:{id:node.attributes.extra.id},scripts:true,callback:function(){Ext.getCmp("gridTabPanel").el.unmask()}})},scope:this},{text:"Delete",ref:"../removeBtn",iconCls:"fa-remove colorDanger",disabled:true,handler:function(){var node=this.tree.panel.getSelectionModel().getSelectedNode();FR.editFieldSet.formPanel.bwrap.mask(FR.T("Please wait..."));Ext.Ajax.request({url:FR.URLRoot+FR.modules.metadata_fields.url.del,params:{id:node.attributes.extra.id},callback:function(){if(FR.editFieldSet.formPanel.bwrap){FR.editFieldSet.formPanel.bwrap.unmask()}},success:function(req){try{var rs=Ext.util.JSON.decode(req.responseText)}catch(er){return false}if(rs){if(rs.success){this.tree.root.removeChild(node);FR.feedback(rs.msg,"success")}else{FR.feedback(rs.msg,"error")}}else{FR.feedback(req.responseText,"error")}},failure:function(f,a){FR.feedback(f.responseText,"error")},scope:this})},scope:this}]}});this.tree.root=new Ext.tree.TreeNode({text:"Root"});this.tree.panel.setRootNode(this.tree.root);Ext.each(FR.setInfo.fields,function(field){this.tree.root.appendChild(new Ext.tree.TreeNode({text:field.name,leaf:true,extra:field}))},this);this.tree.panel.getSelectionModel().on("selectionchange",function(selectionModel,treeNode){this.tree.panel.editBtn.setDisabled(!treeNode);this.tree.panel.removeBtn.setDisabled(!treeNode)},this)}};FR.editFieldSet.getFieldsSelector();FR.editFieldSet.formPanel=new FR.components.editForm({title:FR.T("Edit field set")+" <strong>"+FR.setInfo.name+"</strong>",layout:"form",autoScroll:true,defaults:{labelWidth:140},items:[{xtype:"fieldset",title:"Basic Info",width:500,defaults:{width:250},items:[{xtype:"hidden",name:"id",value:FR.setInfo.id},{xtype:"textfield",fieldLabel:"Field set name",name:"name",value:FR.setInfo.name},{xtype:"textarea",fieldLabel:"Description",name:"description",value:FR.setInfo.description},{xtype:"checkbox",boxLabel:"Generic field set",width:400,value:1,helpText:"A generic field set is one that is available for every file by default.",name:"generic",checked:parseInt(FR.setInfo.generic)}]},{xtype:"fieldset",title:"Fields",width:500,items:FR.editFieldSet.tree.panel}],tbar:[{text:"Save changes",cls:"fr-btn-primary",ref:"saveBtn",handler:function(){var editForm=this.ownerCt.ownerCt;var opts={url:FR.URLRoot+"/?module=metadata&section=cpanel&page=edit_fieldset&action=save",maskText:"Saving changes..."};editForm.submitForm(opts)}},{text:"Delete field set",iconCls:"fa-remove colorDanger",style:"margin-left:10px",handler:function(){FR.editFieldSet.deleteHandler()}}]});FR.editFieldSet.deleteHandler=function(){new Ext.ux.prompt({text:"Please confirm field set deletion.",confirmHandler:function(){var opts={url:FR.URLRoot+"/?module=metadata&section=cpanel&page=delete_fieldset&id="+FR.setInfo.id,maskText:"Please wait..."};FR.editFieldSet.formPanel.deleteAction(opts)}})};Ext.getCmp("gridTabPanel").add(FR.editFieldSet.formPanel);FR.editFieldSet.formPanel.show();