Ext.namespace("Zarafa.plugins.files.backend.Owncloud");
Zarafa.plugins.files.backend.Owncloud.OwncloudBackend=Ext.extend(Zarafa.core.Plugin,{constructor:function(a){a=a||{};Zarafa.plugins.files.backend.Owncloud.OwncloudBackend.superclass.constructor.call(this,a)},initPlugin:function(){Zarafa.plugins.files.backend.Owncloud.OwncloudBackend.superclass.initPlugin.apply(this,arguments);this.registerInsertionPoint("plugin.files.sharedialog",this.createShareDialogInsertionPoint,this);Zarafa.core.data.SharedComponentType.addProperty("filesplugin.owncloud.useredit")},createShareDialogInsertionPoint:function(){return{xtype:"filesplugin.owncloud.filessharedialogpanel"}},
bidSharedComponent:function(a,b){var c=-1;switch(a){case Zarafa.core.data.SharedComponentType["filesplugin.owncloud.useredit"]:c=1}return c},getSharedComponent:function(a,b){var c;switch(a){case Zarafa.core.data.SharedComponentType["filesplugin.owncloud.useredit"]:c=Zarafa.plugins.files.backend.Owncloud.ui.FilesShareUserEditContentPanel}return c}});
Zarafa.onReady(function(){container.registerPlugin(new Zarafa.core.PluginMetaData({name:"filesbackendOwncloud",displayName:dgettext("plugin_filesbackendOwncloud","Files: ownCloud Backend"),allowUserDisable:!1,pluginConstructor:Zarafa.plugins.files.backend.Owncloud.OwncloudBackend}))});Ext.namespace("Zarafa.plugins.files.backend.Owncloud.data");Zarafa.plugins.files.backend.Owncloud.data.RecipientTypes=Zarafa.core.Enum.create({USER:0,GROUP:1,LINK:3});Ext.namespace("Zarafa.plugins.files.backend.Owncloud.data");
Zarafa.plugins.files.backend.Owncloud.data.ResponseHandler=Ext.extend(Zarafa.core.data.AbstractResponseHandler,{successCallback:null,failureCallback:null,doLoadsharingdetails:function(a){this.successCallback(a)},doCreatenewshare:function(a){this.successCallback(a)},doDeleteexistingshare:function(a){this.successCallback(a)},doUpdateexistingshare:function(a){this.successCallback(a)},doError:function(a){Zarafa.common.dialogs.MessageBox.show({title:a.header,msg:a.message,icon:Zarafa.common.dialogs.MessageBox.ERROR,
buttons:Zarafa.common.dialogs.MessageBox.OK});this.failureCallback(a)}});Ext.reg("filesplugin.owncloud.responsehandler",Zarafa.plugins.files.backend.Owncloud.data.ResponseHandler);Ext.namespace("Zarafa.plugins.files.backend.Owncloud.data");
Zarafa.plugins.files.backend.Owncloud.data.ShareGridRecord=Ext.data.Record.create({name:"id",type:"string"},{name:"shareWith",type:"string"},{name:"shareWithDisplayname",type:"string"},{name:"type",type:"string"},{name:"permissionCreate",type:"bool"},{name:"permissionChange",type:"bool"},{name:"permissionDelete",type:"bool"},{name:"permissionShare",type:"bool"});Ext.namespace("Zarafa.plugins.files.backend.Owncloud.data");
Zarafa.plugins.files.backend.Owncloud.data.ShareGridStore=Ext.extend(Ext.data.ArrayStore,{constructor:function(a){Zarafa.plugins.files.backend.Owncloud.data.ShareGridStore.superclass.constructor.call(this,{fields:"id shareWith shareWithDisplayname type permissionCreate permissionChange permissionDelete permissionShare".split(" "),fileType:a})}});Ext.reg("filesplugin.owncloud.sharegridstore",Zarafa.plugins.files.backend.Owncloud.data.ShareGridStore);Ext.namespace("Zarafa.plugins.files.backend.Owncloud.data.singleton");
Zarafa.plugins.files.backend.Owncloud.data.singleton.ShareStore=Ext.extend(Object,{store:void 0,init:function(a){this.store=new Zarafa.plugins.files.backend.Owncloud.data.ShareGridStore(a)},addUser:function(a){var b=!1,c=!1,d=!1,e=!1;1<=a.permissions-16&&(e=!0,a.permissions-=16);1<=a.permissions-8&&(d=!0,a.permissions-=8);1<=a.permissions-4&&(b=!0,a.permissions-=4);1<=a.permissions-2&&(c=!0);this.store.loadData([[a.id,a.shareWith,a.shareWithDisplayname,"user",b,c,d,e]],!0)},addGroup:function(a){var b=
!1,c=!1,d=!1,e=!1;1<=a.permissions-16&&(e=!0,a.permissions-=16);1<=a.permissions-8&&(d=!0,a.permissions-=8);1<=a.permissions-4&&(b=!0,a.permissions-=4);1<=a.permissions-2&&(c=!0);this.store.loadData([[a.id,a.shareWith,a.shareWithDisplayname,"group",b,c,d,e]],!0)},getStore:function(){return this.store}});Zarafa.plugins.files.backend.Owncloud.data.singleton.ShareStore=new Zarafa.plugins.files.backend.Owncloud.data.singleton.ShareStore;Ext.namespace("Zarafa.plugins.files.backend.Owncloud.ui");
Zarafa.plugins.files.backend.Owncloud.ui.FilesShareDialogPanel=Ext.extend(Zarafa.plugins.files.ui.dialogs.SharePanel,{loadMask:void 0,passwordChanged:!1,expirationDateChanged:!1,pubUploadChanged:!1,linkShareID:-1,recordId:void 0,parentRecord:void 0,constructor:function(a){a=a||{};var b=a.ownerCt.records[0].get("type");this.recordId=a.ownerCt.records[0].get("folder_id");this.parentRecord=a.ownerCt.records[0];Zarafa.plugins.files.backend.Owncloud.data.singleton.ShareStore.init(b);this.setupGridStoreListeners();
Ext.applyIf(a,{listeners:{afterrender:this.checkSharedRecord},height:450,width:780,items:[{xtype:"fieldset",title:dgettext("plugin_filesbackendOwncloud","Share with user/group"),autoHeight:!0,ref:"userfieldset",items:[{xtype:"filesplugin.owncloud.filesshareusergrid",ref:"../usergrid",height:200,recordId:this.recordId}]},{xtype:"checkbox",fieldLabel:"",boxLabel:dgettext("plugin_filesbackendOwncloud","Share via link"),ref:"linkcheckbox",inputValue:"sharelink",style:{marginTop:"5px",marginLeft:"6px"},
listeners:{check:this.onShareViaLinkChecked.createDelegate(this)}},{xtype:"fieldset",title:dgettext("plugin_filesbackendOwncloud","Share via link"),autoHeight:!0,ref:"linkfieldset",hidden:!0,items:[{layout:"column",border:!1,defaults:{border:!1},anchor:"0",items:[{columnWidth:.95,layout:"form",items:{xtype:"textfield",fieldLabel:dgettext("plugin_filesbackendOwncloud","Public link"),ref:"../../../linkfield",anchor:"100%",selectOnFocus:!0,readOnly:!0}},{columnWidth:.05,items:{xtype:"button",iconCls:"icon_copy_clipboard",
handler:this.onCopyUrl,scope:this}}]},{xtype:"checkbox",fieldLabel:dgettext("plugin_filesbackendOwncloud","Password protect"),boxLabel:"",ref:"../passwordcheckbox",inputValue:"pwprotected",listeners:{check:this.onUsePasswordChecked.createDelegate(this)}},{xtype:"textfield",fieldLabel:dgettext("plugin_filesbackendOwncloud","Password"),ref:"../passwordfield",hidden:!0,inputType:"password",name:"textvalue",listeners:{change:this.onPasswordChange.createDelegate(this),keyup:this.onPasswordChange.createDelegate(this)}},
{xtype:"checkbox",fieldLabel:dgettext("plugin_filesbackendOwncloud","Public upload"),boxLabel:"",hidden:!0,ref:"../editcheckbox",inputValue:"allowediting",listeners:{check:this.onAllowEditingChecked.createDelegate(this)}},{xtype:"checkbox",fieldLabel:dgettext("plugin_filesbackendOwncloud","Expiration date"),boxLabel:"",ref:"../expirationcheckbox",inputValue:"useexpiration",listeners:{check:this.onUseExpirationDateChecked.createDelegate(this)}},{xtype:"datefield",ref:"../expirationfield",hidden:!0,
fieldLabel:dgettext("plugin_filesbackendOwncloud","Date"),minValue:new Date((new Date).getTime()+864E5),width:170,format:"Y-m-d",listeners:{change:this.onExpirationDateChange.createDelegate(this),keyup:this.onExpirationDateChange.createDelegate(this)}}]}],buttons:[{xtype:"button",text:dgettext("plugin_filesbackendOwncloud","Ok"),handler:this.onDoneButtonClick,ref:"../doneButton",scope:this},{xtype:"button",text:dgettext("plugin_filesbackendOwncloud","Cancel"),handler:this.onCancel,scope:this}]});
Zarafa.plugins.files.backend.Owncloud.ui.FilesShareDialogPanel.superclass.constructor.call(this,a)},setupGridStoreListeners:function(){var a=Zarafa.plugins.files.backend.Owncloud.data.singleton.ShareStore.getStore();a.on("add",this.onGridStoreAdd,this);a.on("update",this.onGridStoreUpdate,this);a.on("remove",this.onGridStoreRemove,this)},onGridStoreRemove:function(a,b){""!=b.get("id")&&-1!=b.get("id")&&this.removeShareByID(b.get("id"))},onGridStoreUpdate:function(a,b){this.updateExistingShare(b)},
onGridStoreAdd:function(a,b){if(1!=b.length||-1!=b[0].get("id"))return!0;this.createShare(b[0],a,!1)},onShareViaLinkChecked:function(a,b){b?(this.linkfieldset.show(),this.createShareByLink()):(this.linkfieldset.hide(),this.removeShareByID(this.linkShareID),this.linkShareID=-1)},onUsePasswordChecked:function(a,b){b?this.passwordfield.show():this.passwordfield.hide()},onPasswordChange:function(a,b){this.passwordChanged=!0},onAllowEditingChecked:function(a,b){this.pubUploadChanged=!0},onUseExpirationDateChecked:function(a,
b){b?this.expirationfield.show():this.expirationfield.hide()},onExpirationDateChange:function(){this.expirationDateChanged=!0},onCancel:function(){this.dialog.close()},closeDialog:function(){var a=Zarafa.plugins.files.backend.Owncloud.data.singleton.ShareStore.getStore();a.un("update",this.onGridStoreUpdate,this);a.un("remove",this.onGridStoreRemove,this);this.dialog.close()},closeLoadMask:function(){this.loadMask.hide()},onDoneButtonClick:function(){this.linkcheckbox.getValue()?this.updateExistingShare():
this.closeDialog()},onCopyUrl:function(){this.linkfield.el.dom.select();document.execCommand("copy")},checkSharedRecord:function(){this.loadMask=new Ext.LoadMask(this.getEl(),{msg:dgettext("plugin_filesbackendOwncloud","Loading details...")});Ext.isDefined(this.parentRecord)&&(this.parentRecord.get("type")===Zarafa.plugins.files.data.FileTypes.FOLDER&&this.editcheckbox.show(),!0===this.parentRecord.get("isshared")&&this.initSharedRecord())},initSharedRecord:function(){this.loadMask.show();var a=[this.recordId];
container.getRequest().singleRequest("filesbrowsermodule","loadsharingdetails",{records:a},new Zarafa.plugins.files.backend.Owncloud.data.ResponseHandler({successCallback:this.initGuiFromSharedRecord.createDelegate(this)}))},initGuiFromSharedRecord:function(a){a=a.shares[this.recordId];for(var b in a){var c=a[b];c.shareType===Zarafa.plugins.files.backend.Owncloud.data.RecipientTypes.LINK?(this.linkShareID=b,this.linkfieldset.show(),this.linkcheckbox.suspendEvents(!1),this.linkcheckbox.setValue(!0),
this.linkcheckbox.resumeEvents(),this.linkfield.setValue(c.url),Ext.isEmpty(c.expiration)||(this.expirationcheckbox.setValue(!0),this.expirationfield.setValue(new Date(c.expiration))),Ext.isEmpty(c.shareWith)||(this.passwordcheckbox.setValue(!0),this.passwordfield.setValue("******")),Ext.isEmpty(c.permissions)||7!==parseInt(c.permissions)||(this.editcheckbox.suspendEvents(!1),this.editcheckbox.setValue(!0),this.editcheckbox.resumeEvents())):c.shareType===Zarafa.plugins.files.backend.Owncloud.data.RecipientTypes.GROUP?
Zarafa.plugins.files.backend.Owncloud.data.singleton.ShareStore.addGroup(c):Zarafa.plugins.files.backend.Owncloud.data.singleton.ShareStore.addUser(c);this.doneButton.setDisabled(!1)}this.loadMask.hide()},createShareByLink:function(){this.loadMask.show();var a=[this.recordId],b={shareType:Zarafa.plugins.files.backend.Owncloud.data.RecipientTypes.LINK};container.getRequest().singleRequest("filesbrowsermodule","createnewshare",{records:a,options:b},new Zarafa.plugins.files.backend.Owncloud.data.ResponseHandler({successCallback:this.shareByLinkCreated.createDelegate(this),
failureCallback:this.closeDialog.createDelegate(this)}))},shareByLinkCreated:function(a){a=a.shares[this.recordId.replace(/\/+$/g,"")];this.linkfield.setValue(a.url);this.linkShareID=a.id;var b=this.parentRecord.get("sharedid")||[];b.push(a.id);this.parentRecord.set("sharedid",b);this.parentRecord.set("isshared",!0);this.doneButton.setDisabled(!1);this.loadMask.hide()},removeShareByID:function(a){this.loadMask.show();var b=this.parentRecord.getAccount().get("id");container.getRequest().singleRequest("filesbrowsermodule",
"deleteexistingshare",{records:[a],accountid:b},new Zarafa.plugins.files.backend.Owncloud.data.ResponseHandler({successCallback:this.shareByIDRemoved.createDelegate(this,[a],!0),failureCallback:this.closeDialog.createDelegate(this)}))},shareByIDRemoved:function(a,b){var c=this.parentRecord.get("sharedid")||[],d=c.indexOf(b);-1<d&&c.splice(d,1);this.parentRecord.set("sharedid",c);0==c.length&&this.parentRecord.set("isshared",!1);this.loadMask.hide()},createShare:function(a,b){this.loadMask.show();
var c=[this.recordId],d=this.getPermissions(a),d={shareType:"user"===a.get("type")?Zarafa.plugins.files.backend.Owncloud.data.RecipientTypes.USER:Zarafa.plugins.files.backend.Owncloud.data.RecipientTypes.GROUP,shareWith:a.get("shareWith"),permissions:d,shareWithDisplayname:a.get("shareWithDisplayname")};container.getRequest().singleRequest("filesbrowsermodule","createnewshare",{records:c,options:d},new Zarafa.plugins.files.backend.Owncloud.data.ResponseHandler({successCallback:this.shareCreated.createDelegate(this,
[d,a],!0),failureCallback:this.shareFailed.createDelegate(this,[b,a])}))},shareCreated:function(a,b,c){a=a.shares[this.recordId.replace(/\/+$/g,"")];var d=this.parentRecord.get("sharedid")||[];d.push(a.id);c.data.id=a.id;this.parentRecord.set("sharedid",d);this.parentRecord.set("isshared",!0);b.id=a.id;this.loadMask.hide()},shareFailed:function(a,b){a.remove(b);this.loadMask.hide()},updateExistingShare:function(a){this.loadMask.show();var b={},c=[];Ext.isDefined(a)?(b.permissions=this.getPermissions(a),
c.push(a.get("id"))):(this.passwordChanged&&(b.password=this.passwordfield.getValue()),this.passwordcheckbox.getValue()||(b.password=""),this.pubUploadChanged&&(this.editcheckbox.getValue()?b.permissions=7:b.permissions=1),this.expirationDateChanged&&(b.expireDate=this.expirationfield.getRawValue()),this.expirationcheckbox.getValue()||(b.expireDate=""),c.push(this.linkShareID));container.getRequest().singleRequest("filesbrowsermodule","updateexistingshare",{records:c,accountid:this.parentRecord.getAccount().get("id"),
options:b},new Zarafa.plugins.files.backend.Owncloud.data.ResponseHandler({successCallback:this.shareByLinkUpdated.createDelegate(this,[a]),failureCallback:this.closeLoadMask.createDelegate(this)}))},shareByLinkUpdated:function(a){this.loadMask.hide();Ext.isDefined(a)||this.closeDialog()},getPermissions:function(a){var b=1;a.get("permissionChange")&&(b+=2);a.get("permissionCreate")&&(b+=4);a.get("permissionDelete")&&(b+=8);a.get("permissionShare")&&(b+=16);return b}});
Ext.reg("filesplugin.owncloud.filessharedialogpanel",Zarafa.plugins.files.backend.Owncloud.ui.FilesShareDialogPanel);Ext.namespace("Zarafa.plugins.files.backend.Owncloud.ui");
Zarafa.plugins.files.backend.Owncloud.ui.FilesShareUserEditContentPanel=Ext.extend(Zarafa.core.ui.ContentPanel,{loadMask:void 0,constructor:function(a){Ext.applyIf(a,{layout:"fit",title:dgettext("plugin_filesbackendOwncloud","Share Details"),closeOnSave:!0,model:!0,autoSave:!1,width:480,height:445,items:{xtype:"filesplugin.owncloud.filesshareusereditpanel",record:a.record,store:a.store,recordId:a.recordId}});Zarafa.plugins.files.backend.Owncloud.ui.FilesShareUserEditContentPanel.superclass.constructor.call(this,
a)}});Ext.reg("filesplugin.owncloud.filesshareusereditcontentpanel",Zarafa.plugins.files.backend.Owncloud.ui.FilesShareUserEditContentPanel);Ext.namespace("Zarafa.plugins.files.backend.Owncloud.ui");
Zarafa.plugins.files.backend.Owncloud.ui.FilesShareUserEditPanel=Ext.extend(Ext.form.FormPanel,{record:void 0,store:void 0,recordId:void 0,constructor:function(a){a.record&&(this.record=a.record);a.store&&(this.store=a.store);a.recordId&&(this.recordId=a.recordId);Ext.applyIf(a||{},{labelAlign:"left",defaultType:"textfield",items:this.createPanelItems(),buttons:[{text:dgettext("plugin_filesbackendOwncloud","Save"),handler:this.doSave,scope:this},{text:dgettext("plugin_filesbackendOwncloud","Cancel"),
handler:this.doClose,scope:this}]});Zarafa.plugins.files.backend.Owncloud.ui.FilesShareUserEditPanel.superclass.constructor.call(this,a)},doClose:function(){this.ownerCt.dialog.close()},doSave:function(){var a=this.shareWith.getStore().getAt(this.shareWith.selectedIndex);this.record?(this.record.beginEdit(),a&&(this.record.set("type",this.type.getValue()),this.record.set("shareWith",a.data.shareWith),this.record.set("shareWithDisplayname",a.data.display_name)),this.record.set("permissionShare",this.permissionShare.getValue()),
this.record.set("permissionChange",this.permissionChange.getValue()),this.record.set("permissionCreate",this.store.fileType===Zarafa.plugins.files.data.FileTypes.FOLDER?this.permissionCreate.getValue():!1),this.record.set("permissionDelete",this.store.fileType===Zarafa.plugins.files.data.FileTypes.FOLDER?this.permissionDelete.getValue():!1),this.record.endEdit()):(a=new this.store.recordType({id:-1,type:this.type.getValue(),shareWith:a.data.shareWith,shareWithDisplayname:a.data.display_name,permissionCreate:this.store.fileType===
Zarafa.plugins.files.data.FileTypes.FOLDER?this.permissionCreate.getValue():!1,permissionChange:this.permissionChange.getValue(),permissionDelete:this.store.fileType===Zarafa.plugins.files.data.FileTypes.FOLDER?this.permissionDelete.getValue():!1,permissionShare:this.permissionShare.getValue()}),this.store.add(a));this.ownerCt.dialog.close()},createPanelItems:function(){var a="user",b="",c=!1,d=!1,e=!1,f=!1;this.record&&(a=this.record.get("type"),this.record.get("shareWith"),b=this.record.get("shareWithDisplayname"),
f=this.record.get("permissionShare"),d=this.record.get("permissionChange"),this.store.fileType===Zarafa.plugins.files.data.FileTypes.FOLDER&&(c=this.record.get("permissionCreate"),e=this.record.get("permissionDelete")));d=[{xtype:"checkbox",fieldLabel:dgettext("plugin_filesbackendOwncloud","Re-share"),name:"permissionShare",ref:"../permissionShare",checked:f},{xtype:"checkbox",fieldLabel:dgettext("plugin_filesbackendOwncloud","Change"),name:"permissionChange",ref:"../permissionChange",checked:d}];
this.store.fileType===Zarafa.plugins.files.data.FileTypes.FOLDER&&d.push({xtype:"checkbox",fieldLabel:dgettext("plugin_filesbackendOwncloud","Create"),name:"permissionCreate",ref:"../permissionCreate",checked:c},{xtype:"checkbox",fieldLabel:dgettext("plugin_filesbackendOwncloud","Delete"),name:"permissionDelete",ref:"../permissionDelete",checked:e});return[{xtype:"filesplugin.owncloud.usergrouppredictorfield",fieldLabel:dgettext("plugin_filesbackendOwncloud","Share with"),name:"shareWith",ref:"shareWith",
allowBlank:!1,value:b,recordId:this.recordId},{xtype:"selectbox",fieldLabel:dgettext("plugin_filesbackendOwncloud","Type"),name:"type",ref:"type",allowBlank:!1,value:a,store:[["user","User"],["group","Group"]],mode:"local"},{xtype:"fieldset",title:dgettext("plugin_filesbackendOwncloud","Permissions"),defaults:{labelWidth:89,anchor:"100%",xtype:"textfield"},items:d}]}});Ext.reg("filesplugin.owncloud.filesshareusereditpanel",Zarafa.plugins.files.backend.Owncloud.ui.FilesShareUserEditPanel);Ext.namespace("Zarafa.plugins.files.backend.Owncloud.ui");
Zarafa.plugins.files.backend.Owncloud.ui.FilesShareUserGrid=Ext.extend(Ext.grid.GridPanel,{store:void 0,recordId:void 0,constructor:function(a){a=a||{};this.store=Zarafa.plugins.files.backend.Owncloud.data.singleton.ShareStore.getStore();Ext.applyIf(a,{xtype:"filesplugin.owncloud.filesshareusergrid",ref:"sharegrid",store:this.store,border:!1,baseCls:"shareGrid",enableHdMenu:!1,loadMask:this.initLoadMask(),viewConfig:this.initViewConfig(),sm:this.initSelectionModel(),cm:this.initColumnModel(),listeners:{rowdblclick:this.onRowDblClick,
scope:this},tbar:[{iconCls:"filesplugin_icon_add",text:dgettext("plugin_filesbackendOwncloud","Add"),handler:this.onAdd.createDelegate(this)},"-",{iconCls:"filesplugin_icon_delete",text:dgettext("plugin_filesbackendOwncloud","Delete"),ref:"../removeAccountBtn",disabled:!0,handler:this.onDelete.createDelegate(this)}]});Zarafa.plugins.files.backend.Owncloud.ui.FilesShareUserGrid.superclass.constructor.call(this,a)},initLoadMask:function(){return{msg:dgettext("plugin_filesbackendOwncloud","Loading users and groups")+
"..."}},initViewConfig:function(){return{enableRowBody:!1,forceFit:!0,emptyText:"<div class='emptytext'>"+dgettext("plugin_filesbackendOwncloud","Add users or groups to share files.")+"</div>",deferEmptyText:!1}},initSelectionModel:function(){return new Ext.grid.RowSelectionModel({singleSelect:!0,listeners:{selectionchange:this.onRowSelected}})},initColumnModel:function(){return new Zarafa.plugins.files.backend.Owncloud.ui.FilesShareUserGridColumnModel({fileType:this.store.fileType})},onRowSelected:function(a){this.grid.removeAccountBtn.setDisabled(1!=
a.getCount())},onRowDblClick:function(a,b){Zarafa.core.data.UIFactory.openLayerComponent(Zarafa.core.data.SharedComponentType["filesplugin.owncloud.useredit"],void 0,{store:a.getStore(),record:a.getStore().getAt(b),manager:Ext.WindowMgr,recordId:this.recordId})},onAdd:function(a,b){Zarafa.core.data.UIFactory.openLayerComponent(Zarafa.core.data.SharedComponentType["filesplugin.owncloud.useredit"],void 0,{store:this.store,manager:Ext.WindowMgr,recordId:this.recordId})},onDelete:function(a,b){var c=
this.getSelectionModel().getSelected();if(!c)return!1;this.store.remove(c)}});Ext.reg("filesplugin.owncloud.filesshareusergrid",Zarafa.plugins.files.backend.Owncloud.ui.FilesShareUserGrid);Ext.namespace("Zarafa.plugins.files.backend.Owncloud.ui");
Zarafa.plugins.files.backend.Owncloud.ui.FilesShareUserGridColumnModel=Ext.extend(Zarafa.common.ui.grid.ColumnModel,{constructor:function(a){a=a||{};this.defaultColumns=this.createDefaultColumns(a.fileType);Ext.applyIf(a,{columns:this.defaultColumns,defaults:{sortable:!0}});Ext.apply(this,a);Zarafa.plugins.files.backend.Owncloud.ui.FilesShareUserGridColumnModel.superclass.constructor.call(this,a)},createDefaultColumns:function(a){var b=[{header:dgettext("plugin_filesbackendOwncloud","Name"),dataIndex:"shareWithDisplayname",
flex:1,sortable:!0,tooltip:dgettext("plugin_filesbackendOwncloud","Sort by: Name")},{header:dgettext("plugin_filesbackendOwncloud","Type"),dataIndex:"type",flex:1,align:"center",sortable:!0,renderer:this.shareTypeRenderer,tooltip:dgettext("plugin_filesbackendOwncloud","Sort by: Type")},{header:dgettext("plugin_filesbackendOwncloud","Re-share"),dataIndex:"permissionShare",flex:1,align:"center",sortable:!1,renderer:this.yesNoRenderer},{header:dgettext("plugin_filesbackendOwncloud","Change"),dataIndex:"permissionChange",
flex:1,align:"center",sortable:!1,renderer:this.yesNoRenderer}];a===Zarafa.plugins.files.data.FileTypes.FOLDER&&b.push({header:dgettext("plugin_filesbackendOwncloud","Create"),dataIndex:"permissionCreate",flex:1,align:"center",sortable:!1,renderer:this.yesNoRenderer},{header:dgettext("plugin_filesbackendOwncloud","Delete"),dataIndex:"permissionDelete",flex:1,align:"center",sortable:!1,renderer:this.yesNoRenderer});return b},shareTypeRenderer:function(a,b,c){b.css="shareicon_16_"+a;b.css+=" zarafa-grid-empty-cell";
return""},yesNoRenderer:function(a,b,c){b.css=a?"shareicon_16_yes":"shareicon_16_no";b.css+=" zarafa-grid-empty-cell";return""}});Ext.namespace("Zarafa.plugins.files.backend.Owncloud.ui");
Zarafa.plugins.files.backend.Owncloud.ui.UserGroupPredictorField=Ext.extend(Ext.form.ComboBox,{constructor:function(a){var b=new Ext.data.ArrayStore({proxy:new Ext.data.HttpProxy({method:"GET",url:container.getBasePath()+"index.php"}),method:"GET",baseParams:{load:"custom",name:"files_get_recipients",id:a.recordId},id:1,fields:["display_name","shareWith","object_type"]});a=a||{};Ext.applyIf(a,{store:b,displayField:"display_name",typeAhead:!1,forceSelection:!0,triggerAction:"query",itemId:"predictor",
mode:"remote",minChars:2,emptyText:dgettext("plugin_filesbackendOwncloud","Type to search"),loadingText:dgettext("plugin_filesbackendOwncloud","Loading..."),listEmptyText:dgettext("plugin_filesbackendOwncloud","No results"),itemSelector:"div.ugpredic_search_item",tpl:new Ext.XTemplate('<tpl for=".">','<div class="ugpredic_search_item">',"<h3>",'<tpl if="object_type == Zarafa.plugins.files.backend.Owncloud.data.RecipientTypes.USER"><span><div class="shareicon_16_user">&nbsp;</div></span></tpl>','<tpl if="object_type == Zarafa.plugins.files.backend.Owncloud.data.RecipientTypes.GROUP"><span><div class="shareicon_16_group">&nbsp;</div></span></tpl>',
"{display_name:htmlEncode}","</h3>","</div>","</tpl>","</tpl>"),onSelect:this.onSuggestionSelect,listeners:{invalid:this.onInvalid,scope:this}});Zarafa.plugins.files.backend.Owncloud.ui.UserGroupPredictorField.superclass.constructor.call(this,a)},onSuggestionSelect:function(a){this.setRawValue(a.get("display_name"));this.ownerCt.type.setValue(a.get("object_type")==Zarafa.plugins.files.backend.Owncloud.data.RecipientTypes.USER?"user":"group");this.collapse()},onInvalid:function(){this.isExpanded()&&
(this.store.removeAll(),this.collapse())}});Ext.reg("filesplugin.owncloud.usergrouppredictorfield",Zarafa.plugins.files.backend.Owncloud.ui.UserGroupPredictorField);//# sourceMappingURL=filesbackendOwncloud.js.map
