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

Unified Diff: ui/file_manager/file_manager/foreground/js/metadata_box_controller.js

Issue 2065933005: Quick View: Format metadata. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nit Created 4 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: ui/file_manager/file_manager/foreground/js/metadata_box_controller.js
diff --git a/ui/file_manager/file_manager/foreground/js/metadata_box_controller.js b/ui/file_manager/file_manager/foreground/js/metadata_box_controller.js
index f3fc4e8e68aae79e364f2c1d9fcd8208bcc36347..4b6220035e0094f06384f96481faecb66d557a74 100644
--- a/ui/file_manager/file_manager/foreground/js/metadata_box_controller.js
+++ b/ui/file_manager/file_manager/foreground/js/metadata_box_controller.js
@@ -9,11 +9,13 @@
* @param{!FilesMetadataBox} metadataBox
* @param{!FilesQuickView} quickView
* @param{!QuickViewModel} quickViewModel
+ * @param{!FileMetadataFormatter} fileMetadataFormatter
*
* @constructor
*/
function MetadataBoxController(
- metadataModel, metadataBox, quickView, quickViewModel) {
+ metadataModel, metadataBox, quickView, quickViewModel,
+ fileMetadataFormatter) {
/**
* @type {!MetadataModel}
* @private
@@ -32,6 +34,12 @@ function MetadataBoxController(
*/
this.quickView_ = quickView;
+ /**
+ * @type {!FileMetadataFormatter}
+ * @private
+ */
+ this.fileMetadataFormatter_ = fileMetadataFormatter;
+
// TODO(oka): Add storage to persist the value of
// quickViewModel_.metadataBoxActive.
/**
@@ -40,6 +48,9 @@ function MetadataBoxController(
*/
this.quickViewModel_ = quickViewModel;
+ fileMetadataFormatter.addEventListener(
+ 'date-time-format-changed', this.updateView_.bind(this));
+
quickView.addEventListener(
'metadata-box-active-changed', this.updateView_.bind(this));
@@ -64,8 +75,13 @@ MetadataBoxController.prototype.updateView_ = function() {
if (!this.quickView_.metadataBoxActive) {
return;
}
- var entry = assert(this.quickViewModel_.getSelectedEntry());
- this.metadataModel_.get([entry], MetadataBoxController.GENERAL_METADATA_NAME)
+ var entry = this.quickViewModel_.getSelectedEntry();
+ if (!entry)
+ return;
+ this.metadataModel_
+ .get(
+ [entry],
+ MetadataBoxController.GENERAL_METADATA_NAME.concat(['hosted']))
.then(this.onGeneralMetadataLoaded_.bind(this, entry));
// TODO(oka): Add file type specific metadata.
@@ -80,10 +96,13 @@ MetadataBoxController.prototype.updateView_ = function() {
*/
MetadataBoxController.prototype.onGeneralMetadataLoaded_ = function(
entry, items) {
- // TODO(oka): Format size and modificationTime using fileMetadataFormatter.
var item = items[0];
- if (item.size)
- this.metadataBox_.size = item.size;
- if (item.modificationTime)
- this.metadataBox_.modificationTime = item.modificationTime;
+ if (item.size) {
+ this.metadataBox_.size =
+ this.fileMetadataFormatter_.formatSize(item.size, item.hosted);
+ }
+ if (item.modificationTime) {
+ this.metadataBox_.modificationTime =
+ this.fileMetadataFormatter_.formatModDate(item.modificationTime);
+ }
};

Powered by Google App Engine
This is Rietveld 408576698