diff --git a/index.html b/index.html
index e7cca56..8214268 100644
--- a/index.html
+++ b/index.html
@@ -23,7 +23,7 @@
-
+
@@ -41,6 +41,7 @@
+
@@ -1032,30 +1033,33 @@
diff --git a/js/ctrls/modal.js b/js/ctrls/modal.js
index 8e28c34..64af204 100644
--- a/js/ctrls/modal.js
+++ b/js/ctrls/modal.js
@@ -123,23 +123,60 @@ angular
var self = this;
this.files = _.cloneDeep(files);
- var groupFile = function (files) {
- var i, j, str, arr, folder = {}, tmp = folder;
- for (i = 0; i < files.length; i++) {
- str = files[i].relpath;
- arr = str.split("/");
- for (j = 0; j < arr.length - 1; j++) {
- if (!tmp[arr[j]]) {
- tmp[arr[j]] = {};
+ var groupFiles = function (files) {
+ var createSubFolder = function () {
+ var folder = {
+ dirs : {},
+ files : {},
+ show : false,
+ _selected : false,
+ change : function () {
+ for (var file in this.files) {
+ if (this.files.hasOwnProperty(file)) {
+ this.files[file].selected = this.selected;
+ }
+ }
+ for (var folder in this.dirs) {
+ if (this.dirs.hasOwnProperty(folder)) {
+ this.dirs[folder].selected = this.selected;
+ }
+ }
+ console.log(this);
}
- tmp = tmp[arr[j]];
- }
- tmp[arr[arr.length - 1]] = files[i];
+ };
+ Object.defineProperty(folder, "selected", {
+ get : function () {
+ return this._selected;
+ },
+ set : function (newValue) {
+ this._selected = newValue;
+ this.change();
+ }
+ });
+ Object.defineProperty(folder, "indeterminate", {
+ get : function () {
+ return this._selected;
+ }
+ });
+ return folder;
+ };
+ var folder = createSubFolder(),
+ tmp;
+ for (var i = 0; i < files.length; i++) {
tmp = folder;
+ var str = files[i].relpath;
+ var arr = str.split("/");
+ for (var j = 0; j < arr.length - 1; j++) {
+ if (!tmp.dirs[arr[j]]) {
+ tmp.dirs[arr[j]] = createSubFolder();
+ }
+ tmp = tmp.dirs[arr[j]];
+ }
+ tmp.files[arr[arr.length - 1]] = files[i];
}
return folder;
};
- this.groupedFiles = groupFile(this.files);
+ this.groupedFiles = groupFiles(this.files);
this.inst = $modal.open({
templateUrl: "selectFiles.html",
scope: scope,
diff --git a/js/directives/fileselect.js b/js/directives/fileselect.js
new file mode 100644
index 0000000..d0d01c5
--- /dev/null
+++ b/js/directives/fileselect.js
@@ -0,0 +1,21 @@
+// watches changes in the file upload control (input[file]) and
+// puts the files selected in an attribute
+angular.module("webui.directives.fileselect", []).directive("indeterminate", function () {
+ return {
+ // Restrict the directive so it can only be used as an attribute
+ restrict : "A",
+
+ link : function link (scope, elem, attr) {
+ // Whenever the bound value of the attribute changes we update
+ // the internal 'indeterminate' flag on the attached dom element
+ var watcher = scope.$watch(attr.indeterminate, function (value) {
+ elem[0].indeterminate = value;
+ });
+
+ // Remove the watcher when the directive is destroyed
+ scope.$on("$destroy", function () {
+ watcher();
+ });
+ }
+ };
+});
diff --git a/js/init.js b/js/init.js
index 72fe0ff..ce964e7 100644
--- a/js/init.js
+++ b/js/init.js
@@ -4,7 +4,7 @@ var webui = angular.module('webui', [
'webui.services.modals', 'webui.services.alerts',
'webui.services.settings', 'webui.services.settings.filters',
'webui.filters.bytes','webui.filters.url',
- 'webui.directives.chunkbar', 'webui.directives.dgraph', 'webui.directives.fselect',
+ 'webui.directives.chunkbar', 'webui.directives.dgraph', 'webui.directives.fselect', "webui.directives.fileselect",
'webui.ctrls.download', 'webui.ctrls.nav', 'webui.ctrls.modal', 'webui.ctrls.alert',
'webui.ctrls.props',
// external deps