group file into folder in select file

This commit is contained in:
vitam 2017-07-25 23:03:52 +02:00
parent fc98bc5b31
commit e1ddc82a64
3 changed files with 50 additions and 13 deletions

View File

@ -34,11 +34,11 @@
width: 80px; width: 80px;
} }
.selectFiles > div > .control-label { .selectFiles div .control-label {
font-weight: normal; font-weight: normal;
margin-left: 30px; margin-left: 30px;
} }
.selectFiles > div > .controls { .selectFiles div .controls {
margin-left: 30px; margin-left: 30px;
} }

View File

@ -1028,6 +1028,36 @@
<button class="btn btn-default btn-primary" ng-click="$close()">{{ 'Start' | translate }}</button> <button class="btn btn-default btn-primary" ng-click="$close()">{{ 'Start' | translate }}</button>
</div> </div>
</script> </script>
<!-- }}} -->
<!-- {{{ select files checkbox modal -->
<script type="text/ng-template" id="selectFilesCheckBox.html">
<div ng-repeat="(folder,file) in files">
<!--is's a folder-->
<div ng-if="!file.index || file.index.toString().indexOf('object') >= 0">
<div class="controls">
<label class="checkbox">
<input type="checkbox"/>{{folder}}
</label>
<div class="form-group selectFiles" ng-include="'selectFilesCheckBox.html'" ng-init="files=file">
</div>
</div>
</div>
<!--is's a file-->
<div ng-if="file.index && file.index.toString().indexOf('object') < 0">
<label class="control-label">{{ 'Select to download' | translate }}</label>
<div class="controls">
<label class="checkbox">
<input type="checkbox" ng-model="file.selected"/>{{file.relpath}}
</label>
</div>
<br/>
<br/>
</div>
</div>
</script>
<!-- }}} --> <!-- }}} -->
<!-- {{{ select file modal --> <!-- {{{ select file modal -->
@ -1039,17 +1069,7 @@
<form class="form-horizontal modal-body"> <form class="form-horizontal modal-body">
<fieldset> <fieldset>
<div class="form-group selectFiles"> <div class="form-group selectFiles" ng-include="'selectFilesCheckBox.html'" ng-init="files=selectFiles.groupedFiles">
<div ng-repeat="file in selectFiles.files">
<label class="control-label">{{ 'Select to download' | translate }}</label>
<div class="controls">
<label class="checkbox">
<input type="checkbox" ng-model="file.selected"/>{{file.relpath}}
</label>
</div>
<br /><br />
</div>
</div> </div>
</fieldset> </fieldset>
</form> </form>

View File

@ -123,6 +123,23 @@ angular
var self = this; var self = this;
this.files = _.cloneDeep(files); 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]] = {};
}
tmp = tmp[arr[j]];
}
tmp[arr[arr.length - 1]] = files[i];
tmp = folder;
}
return folder;
};
this.groupedFiles = groupFile(this.files);
this.inst = $modal.open({ this.inst = $modal.open({
templateUrl: "selectFiles.html", templateUrl: "selectFiles.html",
scope: scope, scope: scope,