jenkins-bot has submitted this change and it was merged.
Change subject: Add filename to the media dialog
......................................................................
Add filename to the media dialog
Show the currently used filename at the top of the media dialog so
it can be copied and used in other pages if needed.
Bug: T54459
Change-Id: Ib1844c997189f7ead0656c5a811d3cab70030f89
---
M VisualEditor.php
M modules/ve-mw/dm/models/ve.dm.MWImageModel.js
M modules/ve-mw/i18n/en.json
M modules/ve-mw/i18n/qqq.json
M modules/ve-mw/ui/dialogs/ve.ui.MWMediaDialog.js
M modules/ve-mw/ui/styles/dialogs/ve.ui.MWMediaDialog.css
6 files changed, 46 insertions(+), 6 deletions(-)
Approvals:
Jforrester: Looks good to me, approved
jenkins-bot: Verified
Objections:
Siebrand: There's a problem with this change, please improve
Esanders: There's a problem with this change, please improve
diff --git a/VisualEditor.php b/VisualEditor.php
index 830cb3a..a5be775 100644
--- a/VisualEditor.php
+++ b/VisualEditor.php
@@ -1006,6 +1006,7 @@
'visualeditor-dialog-media-alttext-section',
'visualeditor-dialog-media-change-image',
'visualeditor-dialog-media-choose-image',
+ 'visualeditor-dialog-media-content-filename',
'visualeditor-dialog-media-content-section',
'visualeditor-dialog-media-dimensionseparator',
'visualeditor-dialog-media-goback',
diff --git a/modules/ve-mw/dm/models/ve.dm.MWImageModel.js
b/modules/ve-mw/dm/models/ve.dm.MWImageModel.js
index 958a7d8..7131ae6 100644
--- a/modules/ve-mw/dm/models/ve.dm.MWImageModel.js
+++ b/modules/ve-mw/dm/models/ve.dm.MWImageModel.js
@@ -176,6 +176,8 @@
imgModel.cacheOriginalImageAttributes( attrs );
imgModel.setImageSource( attrs.src );
+ imgModel.setFilename( new mw.Title( attrs.resource.replace(
/^(\.+\/)*/, '' ) ).getMainText() );
+
imgModel.setImageHref( attrs.href );
// Collect all the information
@@ -220,7 +222,7 @@
*/
ve.dm.MWImageModel.prototype.getHashObject = function () {
var hash = {
- normalizedSource: this.getNormalizedImageSource(),
+ filename: this.getFilename(),
altText: this.getAltText(),
type: this.getType(),
alignment: this.getAlignment(),
@@ -260,7 +262,7 @@
* @param {Object} [dimensions] New dimensions of the image
*/
ve.dm.MWImageModel.prototype.changeImageSource = function ( attrs, dimensions
) {
- var newDimensions, remoteFilename,
+ var newDimensions,
imageModel = this;
if ( attrs.mediaType ) {
@@ -271,7 +273,7 @@
}
if ( attrs.resource ) {
this.setImageResourceName( attrs.resource );
- remoteFilename = attrs.resource.replace( /^(\.+\/)*/, '' );
+ this.setFilename( new mw.Title( attrs.resource.replace(
/^(\.+\/)*/, '' ) ).getMainText() );
}
if ( attrs.src ) {
@@ -285,8 +287,8 @@
this.scalable.clearMinDimensions();
// Call for updated scalable
- if ( remoteFilename ) {
- ve.dm.MWImageNode.static.getScalablePromise( remoteFilename
).done( function ( info ) {
+ if ( this.getFilename() ) {
+ ve.dm.MWImageNode.static.getScalablePromise( this.getFilename()
).done( function ( info ) {
imageModel.scalable.setOriginalDimensions( {
width: info.width,
height: info.height
@@ -1112,6 +1114,22 @@
};
/**
+ * Set the filename of the current image
+ * @param {string} filename Image filename
+ */
+ve.dm.MWImageModel.prototype.setFilename = function ( filename ) {
+ this.filename = filename;
+};
+
+/**
+ * Get the filename of the current image
+ * @returns {string} filename Image filename
+ */
+ve.dm.MWImageModel.prototype.getFilename = function () {
+ return this.filename;
+};
+
+/**
* Set image caption document.
*
* @param {ve.dm.Document} Image caption document
diff --git a/modules/ve-mw/i18n/en.json b/modules/ve-mw/i18n/en.json
index 9d580f9..e59719a 100644
--- a/modules/ve-mw/i18n/en.json
+++ b/modules/ve-mw/i18n/en.json
@@ -74,6 +74,7 @@
"visualeditor-dialog-media-change-image": "Change image",
"visualeditor-dialog-media-choose-image": "Use this image",
"visualeditor-dialog-media-content-section": "Caption",
+ "visualeditor-dialog-media-content-filename": "File name",
"visualeditor-dialog-media-dimensionseparator": " × ",
"visualeditor-dialog-media-goback": "Back",
"visualeditor-dialog-media-info-artist": "Uploaded by $1",
diff --git a/modules/ve-mw/i18n/qqq.json b/modules/ve-mw/i18n/qqq.json
index d9e3220..2de2647 100644
--- a/modules/ve-mw/i18n/qqq.json
+++ b/modules/ve-mw/i18n/qqq.json
@@ -84,6 +84,7 @@
"visualeditor-dialog-media-change-image": "Label for the button to
change the current image in the media edit dialog.",
"visualeditor-dialog-media-choose-image": "Label for the button to use
the selected image in the media edit dialog.",
"visualeditor-dialog-media-content-section": "Label for the image
content sub-section.\n{{Identical|Caption}}",
+ "visualeditor-dialog-media-content-filename": "Label for the image
filename.\n",
"visualeditor-dialog-media-dimensionseparator": "Label dimensions
separator in the image size display.{{Optional}}",
"visualeditor-dialog-media-goback": "Label for the button to go back to
edit settings in the media dialog.\n{{Identical|Go back}}",
"visualeditor-dialog-media-info-artist": "Label for the author
information for the image in the media dialog. $1 - Author name.",
diff --git a/modules/ve-mw/ui/dialogs/ve.ui.MWMediaDialog.js
b/modules/ve-mw/ui/dialogs/ve.ui.MWMediaDialog.js
index 3031745..5a25237 100644
--- a/modules/ve-mw/ui/dialogs/ve.ui.MWMediaDialog.js
+++ b/modules/ve-mw/ui/dialogs/ve.ui.MWMediaDialog.js
@@ -207,11 +207,19 @@
// Define fieldsets for image settings
+ // Filename
+ this.filenameFieldset = new OO.ui.FieldsetLayout( {
+ $: this.$,
+ label: ve.msg( 'visualeditor-dialog-media-content-filename' ),
+ icon: 'picture'
+ } );
+
// Caption
this.captionFieldset = new OO.ui.FieldsetLayout( {
$: this.$,
label: ve.msg( 'visualeditor-dialog-media-content-section' ),
- icon: 'parameter'
+ icon: 'parameter',
+ classes: [ 've-ui-mwMediaDialog-caption-fielset']
} );
// Alt text
@@ -370,6 +378,7 @@
// Initialization
this.mediaSearchPanel.$element.append( this.search.$element );
this.generalSettingsPage.$element.append(
+ this.filenameFieldset.$element,
this.captionFieldset.$element,
altTextFieldset.$element
);
@@ -1071,6 +1080,11 @@
// setting up the initial tools according to the model state
this.isSettingUpModel = true;
+ // Filename
+ this.filenameFieldset.setLabel(
+ this.imageModel.getFilename()
+ );
+
// Size widget
this.sizeErrorLabel.$element.hide();
this.sizeWidget.setScalable( this.imageModel.getScalable() );
diff --git a/modules/ve-mw/ui/styles/dialogs/ve.ui.MWMediaDialog.css
b/modules/ve-mw/ui/styles/dialogs/ve.ui.MWMediaDialog.css
index ac996f5..cffc42a 100644
--- a/modules/ve-mw/ui/styles/dialogs/ve.ui.MWMediaDialog.css
+++ b/modules/ve-mw/ui/styles/dialogs/ve.ui.MWMediaDialog.css
@@ -60,3 +60,8 @@
.ve-ui-mwMediaSearchWidget .oo-ui-searchWidget-results {
padding-right: 0;
}
+
+/* HACK: Override ooui specific 2em top margin */
+.ve-ui-mwMediaDialog-caption-fielset.oo-ui-labelElement.oo-ui-fieldsetLayout {
+ margin-top: 0;
+}
--
To view, visit https://gerrit.wikimedia.org/r/183729
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ib1844c997189f7ead0656c5a811d3cab70030f89
Gerrit-PatchSet: 7
Gerrit-Project: mediawiki/extensions/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Mooeypoo <[email protected]>
Gerrit-Reviewer: Esanders <[email protected]>
Gerrit-Reviewer: Jforrester <[email protected]>
Gerrit-Reviewer: Mooeypoo <[email protected]>
Gerrit-Reviewer: Siebrand <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits