Skip to content

Commit 65c5518

Browse files
committed
more changes
1 parent 1e0951a commit 65c5518

File tree

6 files changed

+58
-47
lines changed

6 files changed

+58
-47
lines changed

dist/angular-filemanager.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/js/controllers/main.js

Lines changed: 25 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,11 @@
2121
$scope.viewTemplate = $storage.getItem('viewTemplate') || 'main-table.html';
2222
$scope.fileList = [];
2323
$scope.temps = [];
24-
$rootScope.selectorModalPath = [];
24+
$rootScope.selectedModalPath = [];
2525

2626
$scope.fileNavigator.onRefresh = function() {
27-
$rootScope.selectorModalPath = $scope.fileNavigator.currentPath;
27+
$scope.temps = [];
28+
$rootScope.selectedModalPath = $scope.fileNavigator.currentPath;
2829
};
2930

3031
$scope.setTemplate = function(name) {
@@ -40,15 +41,6 @@
4041
$translate.use($storage.getItem('language') || fileManagerConfig.defaultLang);
4142
};
4243

43-
$scope.touch = function(item) {
44-
window.item = item;
45-
/*
46-
item = item instanceof Item ? item : new Item();
47-
item.revert();
48-
$scope.temp = item;
49-
*/
50-
};
51-
5244
$scope.selectOrUnselect = function(item, $event) {
5345
var indexInTemp = $scope.temps.indexOf(item);
5446
var isRightClick = $event && $event.which == 3;
@@ -108,7 +100,7 @@
108100
};
109101

110102
$scope.singleSelection = function() {
111-
return $scope.temps.length === 1 ? $scope.temps[0] : false;
103+
return $scope.temps.length === 1 && $scope.temps[0];
112104
};
113105

114106
$scope.totalSelecteds = function() {
@@ -145,13 +137,13 @@
145137
};
146138

147139
$scope.openImagePreview = function(item) {
148-
item.inprocess = true;
140+
$scope.apiHandler.inprocess = true;
149141
$scope.modal('imagepreview', null, true)
150142
.find('#imagepreview-target')
151143
.attr('src', item.getUrl(true))
152144
.unbind('load error')
153145
.on('load error', function() {
154-
item.inprocess = false;
146+
$scope.apiHandler.inprocess = false;
155147
$scope.$apply();
156148
});
157149
};
@@ -168,6 +160,11 @@
168160
return returnElement ? element : true;
169161
};
170162

163+
$scope.modalWithPathSelector = function(id) {
164+
$rootScope.selectedModalPath = $scope.fileNavigator.currentPath;
165+
return $scope.modal(id);
166+
};
167+
171168
$scope.isInThisPath = function(path) {
172169
var currentPath = $scope.fileNavigator.currentPath.join('/');
173170
return currentPath.indexOf(path) !== -1;
@@ -186,19 +183,17 @@
186183
};
187184

188185
$scope.copy = function() {
189-
$scope.apiHandler.copy($scope.temps, $rootScope.selectorModalPath).then(function() {
190-
$scope.fileNavigator.refresh();
191-
$scope.modal('copy', true);
192-
});
193-
};
194-
195-
$scope.copyOld = function(item) {
196-
var samePath = item.tempModel.path.join() === item.model.path.join();
197-
if (samePath && $scope.fileNavigator.fileNameExists(item.tempModel.name)) {
198-
item.error = $translate.instant('error_invalid_filename');
199-
return false;
186+
var item = $scope.singleSelection();
187+
if (item) {
188+
var samePath = item.tempModel.path.join() === item.model.path.join();
189+
var nameExists = samePath && $scope.fileNavigator.fileNameExists(item.tempModel.name);
190+
var hasName = item.tempModel.name.trim();
191+
if (!hasName || nameExists) {
192+
$scope.apiHandler.error = $translate.instant('error_invalid_filename');
193+
return false;
194+
}
200195
}
201-
item.copy().then(function() {
196+
$scope.apiHandler.copy($scope.temps, $rootScope.selectedModalPath).then(function() {
202197
$scope.fileNavigator.refresh();
203198
$scope.modal('copy', true);
204199
});
@@ -237,7 +232,7 @@
237232

238233
$scope.move = function() {
239234
$scope.validateSamePath();
240-
$scope.apiHandler.move($scope.temps, $rootScope.selectorModalPath).then(function() {
235+
$scope.apiHandler.move($scope.temps, $rootScope.selectedModalPath).then(function() {
241236
$scope.fileNavigator.refresh();
242237
$scope.modal('move', true);
243238
});
@@ -246,7 +241,7 @@
246241
$scope.rename = function(item) {
247242
var samePath = item.tempModel.path.join() === item.model.path.join();
248243
if (samePath && $scope.fileNavigator.fileNameExists(item.tempModel.name)) {
249-
item.error = $translate.instant('error_invalid_filename');
244+
$scope.apiHandler.error = $translate.instant('error_invalid_filename');
250245
return false;
251246
}
252247
item.rename().then(function() {
@@ -282,7 +277,7 @@
282277

283278
$scope.validateSamePath = function(msg) {
284279
var anyItem = $scope.singleSelection() || $scope.temps[0];
285-
var selectedPath = $rootScope.selectorModalPath.join('/').replace(/^\//, '');
280+
var selectedPath = $rootScope.selectedModalPath.join('/').replace(/^\//, '');
286281
var selectedItemsPath = anyItem && anyItem.model.path.join('/').replace(/^\//, '');
287282
if (selectedItemsPath === selectedPath) {
288283
$scope.apiHandler.error = msg || $translate.instant('error_cannot_move_same_path');
@@ -305,5 +300,6 @@
305300
$scope.isWindows = $scope.getQueryParam('server') === 'Windows';
306301
$scope.fileNavigator.refresh();
307302
window.scope = $scope; //dev
303+
window.rootScope = $rootScope; //dev
308304
}]);
309305
})(window, angular, jQuery);

src/js/controllers/selector-controller.js

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,39 +8,50 @@
88
$scope.predicate = ['model.type', 'model.name'];
99
$scope.fileNavigator = new FileNavigator();
1010

11+
//selectedModalPath = path elegido x usuario || filenavigator.currentPath
12+
1113
$scope.order = function(predicate) {
1214
$scope.reverse = ($scope.predicate[1] === predicate) ? !$scope.reverse : false;
1315
$scope.predicate[1] = predicate;
1416
};
1517

1618
$scope.select = function(item) {
17-
$rootScope.selectorModalPath = item.model.fullPath().split('/');
19+
$rootScope.selectedModalPath = item.model.fullPath().split('/');
20+
$scope.modal('selector', true);
21+
};
22+
23+
$scope.selectCurrent = function() {
24+
$rootScope.selectedModalPath = $scope.fileNavigator.currentPath;
1825
$scope.modal('selector', true);
1926
};
2027

2128
$scope.selectedFilesAreChildOfPath = function(item) {
22-
var path = item.model.fullPath().replace(/^\//, '');
29+
var path = item.model.fullPath();
2330
return $scope.temps.find(function(item) {
24-
var itemPath = item.model.fullPath().replace(/^\//, '');
31+
var itemPath = item.model.fullPath();
2532
if (path == itemPath) {
2633
return true;
2734
}
2835
if (path.startsWith(itemPath)) {
2936
//fixme names in same folder like folder-one and folder-one-two
37+
//at the moment fixed hidding affected folders
3038
}
3139
});
3240
};
3341

3442
$rootScope.openNavigator = function(path) {
35-
//fixme getSelectedPath still with last values closing and reopening modal
36-
$scope.fileNavigator.currentPath = path;
37-
$rootScope.selectorModalPath = path;
43+
$scope.fileNavigator.currentPath = path;
3844
$scope.fileNavigator.refresh();
3945
$scope.modal('selector');
4046
};
4147

4248
$rootScope.getSelectedPath = function() {
43-
return ('/' + $rootScope.selectorModalPath.join('/')).replace(/\/\//, '/');
49+
var path = $rootScope.selectedModalPath.filter(Boolean);
50+
var result = '/' + path.join('/');
51+
if ($scope.singleSelection()) {
52+
result += '/' + $scope.singleSelection().tempModel.name;
53+
}
54+
return result.replace(/\/\//, '/');
4455
};
4556

4657
}]);

src/js/entities/item.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,9 @@
1212
perms: new Chmod(model && model.rights),
1313
content: model && model.content || '',
1414
recursive: false,
15-
sizeKb: function() {
16-
return Math.round(this.size / 1024, 1);
17-
},
1815
fullPath: function() {
19-
return ('/' + this.path.join('/') + '/' + this.name).replace(/\/\//, '/');
16+
var path = this.path.filter(Boolean);
17+
return (path.join('/') + '/' + this.name).replace(/\/\//, '/');
2018
}
2119
};
2220

@@ -61,10 +59,10 @@
6159
return deferred.resolve(data);
6260
6361
};
64-
*/
62+
6563
Item.prototype.createFolder = function() {
6664
};
67-
65+
*/
6866
Item.prototype.rename = function() {
6967
var self = this;
7068
var deferred = $q.defer();

src/templates/item-context-menu.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@
2626
</li>
2727

2828
<li ng-show="config.allowedActions.move">
29-
<a href="" tabindex="-1" ng-click="modal('move')">
29+
<a href="" tabindex="-1" ng-click="modalWithPathSelector('move')">
3030
<i class="glyphicon glyphicon-arrow-right"></i> {{'move' | translate}}
3131
</a>
3232
</li>
3333

3434
<li ng-show="config.allowedActions.copy && !selectionHas('dir')">
35-
<a href="" tabindex="-1" ng-click="modal('copy')">
35+
<a href="" tabindex="-1" ng-click="modalWithPathSelector('copy')">
3636
<i class="glyphicon glyphicon-log-out"></i> {{'copy' | translate}}
3737
</a>
3838
</li>

src/templates/modals.html

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,10 @@ <h4 class="modal-title">{{"select_destination_folder" | translate}}</h4>
361361
<div>
362362
<div ng-include="config.tplPath + '/current-folder-breadcrumb.html'"></div>
363363
<div ng-include="config.tplPath + '/main-table-modal.html'"></div>
364+
<hr />
365+
<button class="btn btn-sm btn-default" ng-click="selectCurrent()">
366+
<i class="glyphicon"></i> {{"select_this" | translate}}
367+
</button>
364368
</div>
365369
</div>
366370
<div class="modal-footer">
@@ -379,7 +383,9 @@ <h4 class="modal-title">{{"select_destination_folder" | translate}}</h4>
379383
</code>
380384
</div>
381385
<div class="detail-sources">
382-
<code class="mr5"><b>{{"destination" | translate}}:</b> {{getSelectedPath()}}</code>
386+
<code class="mr5">
387+
<b>{{"destination" | translate}}:</b> {{ getSelectedPath() }}
388+
</code>
383389
<a href="" class="label label-primary" ng-click="openNavigator(fileNavigator.currentPath)">
384390
{{'change' | translate}}
385391
</a>

0 commit comments

Comments
 (0)