aboutsummaryrefslogtreecommitdiffstats
path: root/dist/systemtags-systemtags.js
blob: ca73bce01e07aa492d6004e33ebdf03e9c96fcb2 (plain)
1
2
3
/*! For license information please see systemtags-systemtags.js.LICENSE.txt */
(()=>{var e,s={30213:()=>{OCA.SystemTags||(OCA.SystemTags={}),OCA.SystemTags.App={initFileList(e){if(this._fileList)return this._fileList;const s=new URL(window.location.href).searchParams.get("tags"),i=s?s.split(",").map(parseInt):[];return this._fileList=new OCA.SystemTags.FileList(e,{id:"systemtags",fileActions:this._createFileActions(),config:OCA.Files.App.getFilesConfig(),shown:!0,systemTagIds:i}),this._fileList.appName=t("systemtags","Tags"),this._fileList},removeFileList(){this._fileList&&this._fileList.$fileList.empty()},_createFileActions(){const t=new OCA.Files.FileActions;return t.registerDefaultActions(),t.merge(OCA.Files.fileActions),this._globalActionsInitialized||(this._onActionsUpdated=_.bind(this._onActionsUpdated,this),OCA.Files.fileActions.on("setDefault.app-systemtags",this._onActionsUpdated),OCA.Files.fileActions.on("registerAction.app-systemtags",this._onActionsUpdated),this._globalActionsInitialized=!0),t.register("dir","Open",OC.PERMISSION_READ,"",(function(t,e){OCA.Files.App.setActiveView("files",{silent:!0}),OCA.Files.App.fileList.changeDirectory(OC.joinPaths(e.$file.attr("data-path"),t),!0,!0)})),t.setDefault("dir","Open"),t},_onActionsUpdated(t){this._fileList&&(t.action?this._fileList.fileActions.registerAction(t.action):t.defaultAction&&this._fileList.fileActions.setDefault(t.defaultAction.mime,t.defaultAction.name))},destroy(){OCA.Files.fileActions.off("setDefault.app-systemtags",this._onActionsUpdated),OCA.Files.fileActions.off("registerAction.app-systemtags",this._onActionsUpdated),this.removeFileList(),this._fileList=null,delete this._globalActionsInitialized}},window.addEventListener("DOMContentLoaded",(function(){$("#app-content-systemtagsfilter").on("show",(function(t){OCA.SystemTags.App.initFileList($(t.target))})),$("#app-content-systemtagsfilter").on("hide",(function(){OCA.SystemTags.App.removeFileList()}))}))},19294:(t,e,s)=>{"use strict";s(30213),s(99641);var i=s(93379),l=s.n(i),n=s(7795),a=s.n(n),o=s(90569),r=s.n(o),d=s(3565),c=s.n(d),p=s(19216),h=s.n(p),f=s(44589),g=s.n(f),m=s(79891),A={};A.styleTagTransform=g(),A.setAttributes=c(),A.insert=r().bind(null,"head"),A.domAPI=a(),A.insertStyleElement=h(),l()(m.Z,A),m.Z&&m.Z.locals&&m.Z.locals,window.OCA.SystemTags=OCA.SystemTags},99641:()=>{!function(){const e=function(t,e){this.initialize(t,e)};e.prototype=_.extend({},OCA.Files.FileList.prototype,{id:"systemtagsfilter",appName:t("systemtags","Tagged files"),_systemTagIds:[],_lastUsedTags:[],_clientSideSort:!0,_allowSelection:!1,_filterField:null,initialize(t,e){if(OCA.Files.FileList.prototype.initialize.apply(this,arguments),this.initialized)return;e&&e.systemTagIds&&(this._systemTagIds=e.systemTagIds),OC.Plugins.attach("OCA.SystemTags.FileList",this);const s=this.$el.find(".files-controls").empty();_.defer(_.bind(this._getLastUsedTags,this)),this._initFilterField(s)},destroy(){this.$filterField.remove(),OCA.Files.FileList.prototype.destroy.apply(this,arguments)},_getLastUsedTags(){const t=this;$.ajax({type:"GET",url:OC.generateUrl("/apps/systemtags/lastused"),success(e){t._lastUsedTags=e}})},_initFilterField(e){const s=this;return this.$filterField=$('<input type="hidden" name="tags"/>'),this.$filterField.val(this._systemTagIds.join(",")),e.append(this.$filterField),this.$filterField.select2({placeholder:t("systemtags","Select tags to filter by"),allowClear:!1,multiple:!0,toggleSelect:!0,separator:",",query:_.bind(this._queryTagsAutocomplete,this),id:t=>t.id,initSelection(t,e){const i=$(t).val().trim();if(i){const l=i.split(","),n=[];OC.SystemTags.collection.fetch({success(){_.each(l,(function(t){const e=OC.SystemTags.collection.get(t);_.isUndefined(e)||n.push(e.toJSON())})),e(n),s._onTagsChanged({target:t})}})}else e([])},formatResult:t=>OC.SystemTags.getDescriptiveTag(t),formatSelection:t=>OC.SystemTags.getDescriptiveTag(t).outerHTML,sortResults:t=>(t.sort((function(t,e){const i=s._lastUsedTags.indexOf(t.id),l=s._lastUsedTags.indexOf(e.id);return i!==l?-1===l?-1:-1===i?1:i<l?-1:1:OC.Util.naturalSortCompare(t.name,e.name)})),t),escapeMarkup:t=>t,formatNoMatches:()=>t("systemtags","No tags found")}),this.$filterField.parent().children(".select2-container").attr("aria-expanded","false"),this.$filterField.on("select2-open",(()=>{this.$filterField.parent().children(".select2-container").attr("aria-expanded","true")})),this.$filterField.on("select2-close",(()=>{this.$filterField.parent().children(".select2-container").attr("aria-expanded","false")})),this.$filterField.on("change",_.bind(this._onTagsChanged,this)),this.$filterField},_queryTagsAutocomplete(t){OC.SystemTags.collection.fetch({success(){const e=OC.SystemTags.collection.filterByName(t.term);t.callback({results:_.invoke(e,"toJSON")})}})},_onUrlChanged(t){if(t.dir){const e=_.filter(t.dir.split("/"),(function(t){return""!==t.trim()}));this.$filterField.select2("val",e||[]),this._systemTagIds=e,this.reload()}},_onTagsChanged(t){const e=$(t.target).val().trim();this._systemTagIds=""!==e?e.split(","):[],this.$el.trigger($.Event("changeDirectory",{dir:this._systemTagIds.join("/")})),this.reload()},updateEmptyContent(){"/"===this.getCurrentDirectory()?(this._systemTagIds.length?this.$el.find(".emptyfilelist.emptycontent").html('<div class="icon-systemtags"></div><h2>'+t("systemtags","No files found for the selected tags")+"</h2>"):this.$el.find(".emptyfilelist.emptycontent").html('<div class="icon-systemtags"></div><h2>'+t("systemtags","Please select tags to filter by")+"</h2>"),this.$el.find(".emptyfilelist.emptycontent").toggleClass("hidden",!this.isEmpty),this.$el.find(".files-filestable thead th").toggleClass("hidden",this.isEmpty)):OCA.Files.FileList.prototype.updateEmptyContent.apply(this,arguments)},getDirectoryPermissions:()=>OC.PERMISSION_READ|OC.PERMISSION_DELETE,updateStorageStatistics(){},reload(){if(this._setCurrentDir("/",!1),!this._systemTagIds.length)return this.updateEmptyContent(),this.setFiles([]),$.Deferred().resolve();this._selectedFiles={},this._selectionSummary.clear(),this._currentFileModel&&this._currentFileModel.off(),this._currentFileModel=null,this.$el.find(".select-all").prop("checked",!1),this.showMask(),this._reloadCall=this.filesClient.getFilteredFiles({systemTagIds:this._systemTagIds},{properties:this._getWebdavProperties()}),this._detailsView&&this._updateDetailsView(null);const t=this.reloadCallback.bind(this);return this._reloadCall.then(t,t)},reloadCallback(t,e){return e&&e.unshift({}),OCA.Files.FileList.prototype.reloadCallback.call(this,t,e)}}),OCA.SystemTags.FileList=e}()},79891:(t,e,s)=>{"use strict";s.d(e,{Z:()=>o});var i=s(87537),l=s.n(i),n=s(23645),a=s.n(n)()(l());a.push([t.id,"#app-content-systemtagsfilter .select2-container{width:30%;margin-left:10px}#app-sidebar .app-sidebar-header__action .tag-label{cursor:pointer;padding:13px 0;display:flex;color:var(--color-text-light);position:relative;margin-top:-20px}","",{version:3,sources:["webpack://./apps/systemtags/src/css/systemtagsfilelist.scss"],names:[],mappings:"AASA,iDACC,SAAA,CACA,gBAAA,CAGD,oDACC,cAAA,CACA,cAAA,CACA,YAAA,CACA,6BAAA,CACA,iBAAA,CACA,gBAAA",sourcesContent:["/*\n * Copyright (c) 2016\n *\n * This file is licensed under the Affero General Public License version 3\n * or later.\n *\n * See the COPYING-README file.\n *\n */\n#app-content-systemtagsfilter .select2-container {\n\twidth: 30%;\n\tmargin-left: 10px;\n}\n\n#app-sidebar .app-sidebar-header__action .tag-label {\n\tcursor: pointer;\n\tpadding: 13px 0;\n\tdisplay: flex;\n\tcolor: var(--color-text-light);\n\tposition: relative;\n\tmargin-top: -20px;\n}\n"],sourceRoot:""}]);const o=a}},i={};function l(t){var e=i[t];if(void 0!==e)return e.exports;var n=i[t]={id:t,loaded:!1,exports:{}};return s[t].call(n.exports,n,n.exports,l),n.loaded=!0,n.exports}l.m=s,e=[],l.O=(t,s,i,n)=>{if(!s){var a=1/0;for(c=0;c<e.length;c++){s=e[c][0],i=e[c][1],n=e[c][2];for(var o=!0,r=0;r<s.length;r++)(!1&n||a>=n)&&Object.keys(l.O).every((t=>l.O[t](s[r])))?s.splice(r--,1):(o=!1,n<a&&(a=n));if(o){e.splice(c--,1);var d=i();void 0!==d&&(t=d)}}return t}n=n||0;for(var c=e.length;c>0&&e[c-1][2]>n;c--)e[c]=e[c-1];e[c]=[s,i,n]},l.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return l.d(e,{a:e}),e},l.d=(t,e)=>{for(var s in e)l.o(e,s)&&!l.o(t,s)&&Object.defineProperty(t,s,{enumerable:!0,get:e[s]})},l.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),l.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),l.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},l.nmd=t=>(t.paths=[],t.children||(t.children=[]),t),l.j=9698,(()=>{l.b=document.baseURI||self.location.href;var t={9698:0};l.O.j=e=>0===t[e];var e=(e,s)=>{var i,n,a=s[0],o=s[1],r=s[2],d=0;if(a.some((e=>0!==t[e]))){for(i in o)l.o(o,i)&&(l.m[i]=o[i]);if(r)var c=r(l)}for(e&&e(s);d<a.length;d++)n=a[d],l.o(t,n)&&t[n]&&t[n][0](),t[n]=0;return l.O(c)},s=self.webpackChunknextcloud=self.webpackChunknextcloud||[];s.forEach(e.bind(null,0)),s.push=e.bind(null,s.push.bind(s))})(),l.nc=void 0;var n=l.O(void 0,[7874],(()=>l(19294)));n=l.O(n)})();
//# sourceMappingURL=systemtags-systemtags.js.map?v=3d68c59f2596519769b5