Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(17)

Side by Side Diff: ui/file_manager/gallery/js/gallery_item.js

Issue 397543002: Gallery.app: Don't dispatch an event to update when renaming is not done. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/file_manager/gallery/js/gallery.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 'use strict'; 5 'use strict';
6 6
7 /** 7 /**
8 * Object representing an image item (a photo). 8 * Object representing an image item (a photo).
9 * 9 *
10 * @param {FileEntry} entry Image entry. 10 * @param {FileEntry} entry Image entry.
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 saveToDir(overrideDir); 248 saveToDir(overrideDir);
249 } else { 249 } else {
250 this.entry_.getParent(saveToDir, onError); 250 this.entry_.getParent(saveToDir, onError);
251 } 251 }
252 }; 252 };
253 253
254 /** 254 /**
255 * Renames the item. 255 * Renames the item.
256 * 256 *
257 * @param {string} displayName New display name (without the extension). 257 * @param {string} displayName New display name (without the extension).
258 * @return {Promise} Promise fulfilled after renaming, or rejected with 258 * @return {Promise} Promise fulfilled with when renaming completes, or rejected
259 * GalleryRenameError. 259 * with the error message.
260 */ 260 */
261 Gallery.Item.prototype.rename = function(displayName) { 261 Gallery.Item.prototype.rename = function(displayName) {
262 var newFileName = this.entry_.name.replace( 262 var newFileName = this.entry_.name.replace(
263 ImageUtil.getDisplayNameFromName(this.entry_.name), displayName); 263 ImageUtil.getDisplayNameFromName(this.entry_.name), displayName);
264 264
265 if (newFileName === this.entry_.name) 265 if (newFileName === this.entry_.name)
266 return Promise.resolve(); 266 return Promise.reject('NOT_CHANGED');
267 267
268 if (/^\s*$/.test(displayName)) 268 if (/^\s*$/.test(displayName))
269 return Promise.reject(str('ERROR_WHITESPACE_NAME')); 269 return Promise.reject(str('ERROR_WHITESPACE_NAME'));
270 270
271 var parentDirectoryPromise = new Promise( 271 var parentDirectoryPromise = new Promise(
272 this.entry_.getParent.bind(this.entry_)); 272 this.entry_.getParent.bind(this.entry_));
273 return parentDirectoryPromise.then(function(parentDirectory) { 273 return parentDirectoryPromise.then(function(parentDirectory) {
274 var nameValidatingPromise = 274 var nameValidatingPromise =
275 util.validateFileName(parentDirectory, newFileName, true); 275 util.validateFileName(parentDirectory, newFileName, true);
276 return nameValidatingPromise.then(function() { 276 return nameValidatingPromise.then(function() {
277 var existingFilePromise = new Promise(parentDirectory.getFile.bind( 277 var existingFilePromise = new Promise(parentDirectory.getFile.bind(
278 parentDirectory, newFileName, {create: false, exclusive: false})); 278 parentDirectory, newFileName, {create: false, exclusive: false}));
279 return existingFilePromise.then(function() { 279 return existingFilePromise.then(function() {
280 return Promise.reject(str('GALLERY_FILE_EXISTS')); 280 return Promise.reject(str('GALLERY_FILE_EXISTS'));
281 }, function() { 281 }, function() {
282 return new Promise( 282 return new Promise(
283 this.entry_.moveTo.bind(this.entry_, parentDirectory, newFileName)); 283 this.entry_.moveTo.bind(this.entry_, parentDirectory, newFileName));
284 }.bind(this)); 284 }.bind(this));
285 }.bind(this)); 285 }.bind(this));
286 }.bind(this)).then(function(entry) { 286 }.bind(this)).then(function(entry) {
287 this.entry_ = entry; 287 this.entry_ = entry;
288 }.bind(this)); 288 }.bind(this));
289 }; 289 };
OLDNEW
« no previous file with comments | « ui/file_manager/gallery/js/gallery.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698