nextcloud/apps/systemtags/js/systemtags.js

75 lines
17 KiB
JavaScript

!function(e){var t={};function i(s){if(t[s])return t[s].exports;var n=t[s]={i:s,l:!1,exports:{}};return e[s].call(n.exports,n,n.exports,i),n.l=!0,n.exports}i.m=e,i.c=t,i.d=function(e,t,s){i.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:s})},i.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i.t=function(e,t){if(1&t&&(e=i(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var s=Object.create(null);if(i.r(s),Object.defineProperty(s,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var n in e)i.d(s,n,function(t){return e[t]}.bind(null,n));return s},i.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return i.d(t,"a",t),t},i.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},i.p="/js/",i(i.s=8)}([function(e,t,i){"use strict";var s=i(2),n=i.n(s),o=i(3),a=i.n(o)()(n.a);a.push([e.i,"#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}\n","",{version:3,sources:["webpack://./apps/systemtags/src/css/systemtagsfilelist.scss"],names:[],mappings:"AASA,iDACC,SAAU,CACV,gBAAiB,CACjB,oDAGA,cAAe,CACf,cAAe,CACf,YAAa,CACb,6BAA8B,CAC9B,iBAAkB,CAClB,gBAAiB",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:""}]),t.a=a},function(e,t,i){"use strict";var s,n=function(){return void 0===s&&(s=Boolean(window&&document&&document.all&&!window.atob)),s},o=function(){var e={};return function(t){if(void 0===e[t]){var i=document.querySelector(t);if(window.HTMLIFrameElement&&i instanceof window.HTMLIFrameElement)try{i=i.contentDocument.head}catch(e){i=null}e[t]=i}return e[t]}}(),a=[];function r(e){for(var t=-1,i=0;i<a.length;i++)if(a[i].identifier===e){t=i;break}return t}function l(e,t){for(var i={},s=[],n=0;n<e.length;n++){var o=e[n],l=t.base?o[0]+t.base:o[0],c=i[l]||0,d="".concat(l," ").concat(c);i[l]=c+1;var u=r(d),f={css:o[1],media:o[2],sourceMap:o[3]};-1!==u?(a[u].references++,a[u].updater(f)):a.push({identifier:d,updater:m(f,t),references:1}),s.push(d)}return s}function c(e){var t=document.createElement("style"),s=e.attributes||{};if(void 0===s.nonce){var n=i.nc;n&&(s.nonce=n)}if(Object.keys(s).forEach((function(e){t.setAttribute(e,s[e])})),"function"==typeof e.insert)e.insert(t);else{var a=o(e.insert||"head");if(!a)throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");a.appendChild(t)}return t}var d,u=(d=[],function(e,t){return d[e]=t,d.filter(Boolean).join("\n")});function f(e,t,i,s){var n=i?"":s.media?"@media ".concat(s.media," {").concat(s.css,"}"):s.css;if(e.styleSheet)e.styleSheet.cssText=u(t,n);else{var o=document.createTextNode(n),a=e.childNodes;a[t]&&e.removeChild(a[t]),a.length?e.insertBefore(o,a[t]):e.appendChild(o)}}function p(e,t,i){var s=i.css,n=i.media,o=i.sourceMap;if(n?e.setAttribute("media",n):e.removeAttribute("media"),o&&"undefined"!=typeof btoa&&(s+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(o))))," */")),e.styleSheet)e.styleSheet.cssText=s;else{for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(document.createTextNode(s))}}var h=null,g=0;function m(e,t){var i,s,n;if(t.singleton){var o=g++;i=h||(h=c(t)),s=f.bind(null,i,o,!1),n=f.bind(null,i,o,!0)}else i=c(t),s=p.bind(null,i,t),n=function(){!function(e){if(null===e.parentNode)return!1;e.parentNode.removeChild(e)}(i)};return s(e),function(t){if(t){if(t.css===e.css&&t.media===e.media&&t.sourceMap===e.sourceMap)return;s(e=t)}else n()}}e.exports=function(e,t){(t=t||{}).singleton||"boolean"==typeof t.singleton||(t.singleton=n());var i=l(e=e||[],t);return function(e){if(e=e||[],"[object Array]"===Object.prototype.toString.call(e)){for(var s=0;s<i.length;s++){var n=r(i[s]);a[n].references--}for(var o=l(e,t),c=0;c<i.length;c++){var d=r(i[c]);0===a[d].references&&(a[d].updater(),a.splice(d,1))}i=o}}}},function(e,t,i){"use strict";function s(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var i=[],s=!0,n=!1,o=void 0;try{for(var a,r=e[Symbol.iterator]();!(s=(a=r.next()).done)&&(i.push(a.value),!t||i.length!==t);s=!0);}catch(e){n=!0,o=e}finally{try{s||null==r.return||r.return()}finally{if(n)throw o}}return i}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return n(e,t);var i=Object.prototype.toString.call(e).slice(8,-1);"Object"===i&&e.constructor&&(i=e.constructor.name);if("Map"===i||"Set"===i)return Array.from(e);if("Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i))return n(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function n(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,s=new Array(t);i<t;i++)s[i]=e[i];return s}e.exports=function(e){var t=s(e,4),i=t[1],n=t[3];if("function"==typeof btoa){var o=btoa(unescape(encodeURIComponent(JSON.stringify(n)))),a="sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(o),r="/*# ".concat(a," */"),l=n.sources.map((function(e){return"/*# sourceURL=".concat(n.sourceRoot||"").concat(e," */")}));return[i].concat(l).concat([r]).join("\n")}return[i].join("\n")}},function(e,t,i){"use strict";e.exports=function(e){var t=[];return t.toString=function(){return this.map((function(t){var i=e(t);return t[2]?"@media ".concat(t[2]," {").concat(i,"}"):i})).join("")},t.i=function(e,i,s){"string"==typeof e&&(e=[[null,e,""]]);var n={};if(s)for(var o=0;o<this.length;o++){var a=this[o][0];null!=a&&(n[a]=!0)}for(var r=0;r<e.length;r++){var l=[].concat(e[r]);s&&n[l[0]]||(i&&(l[2]?l[2]="".concat(i," and ").concat(l[2]):l[2]=i),t.push(l))}},t}},function(e,i){OCA.SystemTags||(OCA.SystemTags={}),OCA.SystemTags.App={initFileList(e){return this._fileList||(this._fileList=new OCA.SystemTags.FileList(e,{id:"systemtags",fileActions:this._createFileActions(),config:OCA.Files.App.getFilesConfig(),shown:!0}),this._fileList.appName=t("systemtags","Tags")),this._fileList},removeFileList(){this._fileList&&this._fileList.$fileList.empty()},_createFileActions(){const e=new OCA.Files.FileActions;return e.registerDefaultActions(),e.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),e.register("dir","Open",OC.PERMISSION_READ,"",(function(e,t){OCA.Files.App.setActiveView("files",{silent:!0}),OCA.Files.App.fileList.changeDirectory(OC.joinPaths(t.$file.attr("data-path"),e),!0,!0)})),e.setDefault("dir","Open"),e},_onActionsUpdated(e){this._fileList&&(e.action?this._fileList.fileActions.registerAction(e.action):e.defaultAction&&this._fileList.fileActions.setDefault(e.defaultAction.mime,e.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(e){OCA.SystemTags.App.initFileList($(e.target))})),$("#app-content-systemtagsfilter").on("hide",(function(){OCA.SystemTags.App.removeFileList()}))}))},function(e,i){
/**
* Copyright (c) 2016 Vincent Petry <pvince81@owncloud.com>
*
* @author Joas Schilling <coding@schilljs.com>
* @author John Molakvoæ <skjnldsv@protonmail.com>
* @author Vincent Petry <vincent@nextcloud.com>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
!function(){const e=function(e,t){this.initialize(e,t)};e.prototype=_.extend({},OCA.Files.FileList.prototype,{id:"systemtagsfilter",appName:t("systemtags","Tagged files"),_systemTagIds:[],_lastUsedTags:[],_clientSideSort:!0,_allowSelection:!1,_filterField:null,initialize(e,t){if(OCA.Files.FileList.prototype.initialize.apply(this,arguments),this.initialized)return;t&&t.systemTagIds&&(this._systemTagIds=t.systemTagIds),OC.Plugins.attach("OCA.SystemTags.FileList",this);const i=this.$el.find("#controls").empty();_.defer(_.bind(this._getLastUsedTags,this)),this._initFilterField(i)},destroy(){this.$filterField.remove(),OCA.Files.FileList.prototype.destroy.apply(this,arguments)},_getLastUsedTags(){const e=this;$.ajax({type:"GET",url:OC.generateUrl("/apps/systemtags/lastused"),success(t){e._lastUsedTags=t}})},_initFilterField(e){const i=this;return this.$filterField=$('<input type="hidden" name="tags"/>'),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:e=>e.id,initSelection(e,t){const i=$(e).val().trim();if(i){const e=i.split(","),s=[];OC.SystemTags.collection.fetch({success(){_.each(e,(function(e){const t=OC.SystemTags.collection.get(e);_.isUndefined(t)||s.push(t.toJSON())})),t(s)}})}else t([])},formatResult:e=>OC.SystemTags.getDescriptiveTag(e),formatSelection:e=>OC.SystemTags.getDescriptiveTag(e)[0].outerHTML,sortResults:e=>(e.sort((function(e,t){const s=i._lastUsedTags.indexOf(e.id),n=i._lastUsedTags.indexOf(t.id);return s!==n?-1===n?-1:-1===s?1:s<n?-1:1:OC.Util.naturalSortCompare(e.name,t.name)})),e),escapeMarkup:e=>e,formatNoMatches:()=>t("systemtags","No tags found")}),this.$filterField.on("change",_.bind(this._onTagsChanged,this)),this.$filterField},_queryTagsAutocomplete(e){OC.SystemTags.collection.fetch({success(){const t=OC.SystemTags.collection.filterByName(e.term);e.callback({results:_.invoke(t,"toJSON")})}})},_onUrlChanged(e){if(e.dir){const t=_.filter(e.dir.split("/"),(function(e){return""!==e.trim()}));this.$filterField.select2("val",t||[]),this._systemTagIds=t,this.reload()}},_onTagsChanged(e){const t=$(e.target).val().trim();this._systemTagIds=""!==t?t.split(","):[],this.$el.trigger($.Event("changeDirectory",{dir:this._systemTagIds.join("/")})),this.reload()},updateEmptyContent(){"/"===this.getCurrentDirectory()?(this._systemTagIds.length?this.$el.find("#emptycontent").html('<div class="icon-systemtags"></div><h2>'+t("systemtags","No files found for the selected tags")+"</h2>"):this.$el.find("#emptycontent").html('<div class="icon-systemtags"></div><h2>'+t("systemtags","Please select tags to filter by")+"</h2>"),this.$el.find("#emptycontent").toggleClass("hidden",!this.isEmpty),this.$el.find("#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 e=this.reloadCallback.bind(this);return this._reloadCall.then(e,e)},reloadCallback(e,t){return t&&t.unshift({}),OCA.Files.FileList.prototype.reloadCallback.call(this,e,t)}}),OCA.SystemTags.FileList=e}()},function(e,t){OCA.SystemTags=_.extend({},OCA.SystemTags),OCA.SystemTags||(OCA.SystemTags={}),OCA.SystemTags.FilesPlugin={ignoreLists:["trashbin","files.public"],attach(e){if(!(this.ignoreLists.indexOf(e.id)>=0||OCA.SystemTags.View)){const t=new OCA.SystemTags.SystemTagsInfoView;e.registerDetailView(t),OCA.SystemTags.View=t}}},OC.Plugins.register("OCA.Files.FileList",OCA.SystemTags.FilesPlugin)},function(e,t){
/**
* Copyright (c) 2015
*
* @author Daniel Calviño Sánchez <danxuliu@gmail.com>
* @author Joas Schilling <coding@schilljs.com>
* @author John Molakvoæ <skjnldsv@protonmail.com>
* @author Julius Härtl <jus@bitgrid.net>
* @author Vincent Petry <vincent@nextcloud.com>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
!function(e){function t(e){const t=e.toJSON();return OC.isUserAdmin()||t.canAssign||(t.locked=!0),t}const i=e.Files.DetailFileInfoView.extend({_rendered:!1,className:"systemTagsInfoView",name:"systemTags",id:"systemTagsInfoView",_inputView:null,initialize(e){const i=this;e=e||{},this._inputView=new OC.SystemTags.SystemTagsInputField({multiple:!0,allowActions:!0,allowCreate:!0,isAdmin:OC.isUserAdmin(),initSelection(e,s){s(i.selectedTagsCollection.map(t))}}),this.selectedTagsCollection=new OC.SystemTags.SystemTagsMappingCollection([],{objectType:"files"}),this._inputView.collection.on("change:name",this._onTagRenamedGlobally,this),this._inputView.collection.on("remove",this._onTagDeletedGlobally,this),this._inputView.on("select",this._onSelectTag,this),this._inputView.on("deselect",this._onDeselectTag,this)},_onSelectTag(e){this.selectedTagsCollection.create(e.toJSON())},_onDeselectTag(e){this.selectedTagsCollection.get(e).destroy()},_onTagRenamedGlobally(e){const t=this.selectedTagsCollection.get(e.id);t&&t.set(e.toJSON())},_onTagDeletedGlobally(e){this.selectedTagsCollection.remove(e)},setFileInfo(e){const i=this;this._rendered||this.render(),e&&(this.selectedTagsCollection.setObjectId(e.id),this.selectedTagsCollection.fetch({success(e){e.fetched=!0;const s=e.map(t);i._inputView.setData(s),s.length>0&&i.show()}})),this.hide()},render(){this.$el.append(this._inputView.$el),this._inputView.render()},isVisible(){return!this.$el.hasClass("hidden")},show(){this.$el.removeClass("hidden")},hide(){this.$el.addClass("hidden")},toggle(){this.$el.toggleClass("hidden")},openDropdown(){this.$el.find(".systemTagsInputField").select2("open")},remove(){this._inputView.remove()}});e.SystemTags.SystemTagsInfoView=i}(OCA)},function(e,t,i){"use strict";i.r(t);i(4),i(5),i(6),i(7);var s=i(1),n=i.n(s),o=i(0),a={insert:"head",singleton:!1};n()(o.a,a),o.a.locals;
/**
* @copyright Copyright (c) 2016 Roeland Jago Douma <roeland@famdouma.nl>
*
* @author John Molakvoæ <skjnldsv@protonmail.com>
* @author Roeland Jago Douma <roeland@famdouma.nl>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
window.OCA.SystemTags=OCA.SystemTags}]);
//# sourceMappingURL=systemtags.js.map