|
21 | 21 | $scope.viewTemplate = $storage.getItem('viewTemplate') || 'main-table.html'; |
22 | 22 | $scope.fileList = []; |
23 | 23 | $scope.temps = []; |
24 | | - $rootScope.selectorModalPath = []; |
| 24 | + $rootScope.selectedModalPath = []; |
25 | 25 |
|
26 | 26 | $scope.fileNavigator.onRefresh = function() { |
27 | | - $rootScope.selectorModalPath = $scope.fileNavigator.currentPath; |
| 27 | + $scope.temps = []; |
| 28 | + $rootScope.selectedModalPath = $scope.fileNavigator.currentPath; |
28 | 29 | }; |
29 | 30 |
|
30 | 31 | $scope.setTemplate = function(name) { |
|
40 | 41 | $translate.use($storage.getItem('language') || fileManagerConfig.defaultLang); |
41 | 42 | }; |
42 | 43 |
|
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 | | - |
52 | 44 | $scope.selectOrUnselect = function(item, $event) { |
53 | 45 | var indexInTemp = $scope.temps.indexOf(item); |
54 | 46 | var isRightClick = $event && $event.which == 3; |
|
108 | 100 | }; |
109 | 101 |
|
110 | 102 | $scope.singleSelection = function() { |
111 | | - return $scope.temps.length === 1 ? $scope.temps[0] : false; |
| 103 | + return $scope.temps.length === 1 && $scope.temps[0]; |
112 | 104 | }; |
113 | 105 |
|
114 | 106 | $scope.totalSelecteds = function() { |
|
145 | 137 | }; |
146 | 138 |
|
147 | 139 | $scope.openImagePreview = function(item) { |
148 | | - item.inprocess = true; |
| 140 | + $scope.apiHandler.inprocess = true; |
149 | 141 | $scope.modal('imagepreview', null, true) |
150 | 142 | .find('#imagepreview-target') |
151 | 143 | .attr('src', item.getUrl(true)) |
152 | 144 | .unbind('load error') |
153 | 145 | .on('load error', function() { |
154 | | - item.inprocess = false; |
| 146 | + $scope.apiHandler.inprocess = false; |
155 | 147 | $scope.$apply(); |
156 | 148 | }); |
157 | 149 | }; |
|
168 | 160 | return returnElement ? element : true; |
169 | 161 | }; |
170 | 162 |
|
| 163 | + $scope.modalWithPathSelector = function(id) { |
| 164 | + $rootScope.selectedModalPath = $scope.fileNavigator.currentPath; |
| 165 | + return $scope.modal(id); |
| 166 | + }; |
| 167 | + |
171 | 168 | $scope.isInThisPath = function(path) { |
172 | 169 | var currentPath = $scope.fileNavigator.currentPath.join('/'); |
173 | 170 | return currentPath.indexOf(path) !== -1; |
|
186 | 183 | }; |
187 | 184 |
|
188 | 185 | $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 | + } |
200 | 195 | } |
201 | | - item.copy().then(function() { |
| 196 | + $scope.apiHandler.copy($scope.temps, $rootScope.selectedModalPath).then(function() { |
202 | 197 | $scope.fileNavigator.refresh(); |
203 | 198 | $scope.modal('copy', true); |
204 | 199 | }); |
|
237 | 232 |
|
238 | 233 | $scope.move = function() { |
239 | 234 | $scope.validateSamePath(); |
240 | | - $scope.apiHandler.move($scope.temps, $rootScope.selectorModalPath).then(function() { |
| 235 | + $scope.apiHandler.move($scope.temps, $rootScope.selectedModalPath).then(function() { |
241 | 236 | $scope.fileNavigator.refresh(); |
242 | 237 | $scope.modal('move', true); |
243 | 238 | }); |
|
246 | 241 | $scope.rename = function(item) { |
247 | 242 | var samePath = item.tempModel.path.join() === item.model.path.join(); |
248 | 243 | 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'); |
250 | 245 | return false; |
251 | 246 | } |
252 | 247 | item.rename().then(function() { |
|
282 | 277 |
|
283 | 278 | $scope.validateSamePath = function(msg) { |
284 | 279 | var anyItem = $scope.singleSelection() || $scope.temps[0]; |
285 | | - var selectedPath = $rootScope.selectorModalPath.join('/').replace(/^\//, ''); |
| 280 | + var selectedPath = $rootScope.selectedModalPath.join('/').replace(/^\//, ''); |
286 | 281 | var selectedItemsPath = anyItem && anyItem.model.path.join('/').replace(/^\//, ''); |
287 | 282 | if (selectedItemsPath === selectedPath) { |
288 | 283 | $scope.apiHandler.error = msg || $translate.instant('error_cannot_move_same_path'); |
|
305 | 300 | $scope.isWindows = $scope.getQueryParam('server') === 'Windows'; |
306 | 301 | $scope.fileNavigator.refresh(); |
307 | 302 | window.scope = $scope; //dev |
| 303 | + window.rootScope = $rootScope; //dev |
308 | 304 | }]); |
309 | 305 | })(window, angular, jQuery); |
0 commit comments