Don't allow table attributes to be edited when hasExpandedAttrs

...but do allow table contents to be edited.

Bug: T307305
Change-Id: I4d714b35d2787d7259aab8250d6a772533dfde2e
This commit is contained in:
Ed Sanders 2023-02-20 15:00:11 +00:00 committed by Esanders
parent 247d4cf042
commit 1d4f828cbd
3 changed files with 20 additions and 10 deletions

View file

@ -34,6 +34,8 @@ OO.mixinClass( ve.dm.MWTableNode, ve.dm.ClassAttributeNode );
ve.dm.MWTableNode.static.name = 'mwTable';
ve.dm.MWTableNode.static.allowedRdfaTypes = [ 'mw:ExpandedAttrs' ];
ve.dm.MWTableNode.static.classAttributes = {
wikitable: { wikitable: true },
sortable: { sortable: true },
@ -57,15 +59,18 @@ ve.dm.TableCaptionNode.static.parentNodeTypes.push( 'mwTable' );
ve.dm.TableRowNode.static.childNodeTypes.push( 'mwTransclusionTableCell' );
ve.dm.MWTableNode.static.toDataElement = function ( domElements ) {
var attributes = {},
dataElement = { type: this.name },
classAttr = domElements[ 0 ].getAttribute( 'class' );
var dataElement = { type: this.name },
domElement = domElements[ 0 ],
classAttr = domElement.getAttribute( 'class' );
var attributes = {
hasExpandedAttrs: ( domElement.getAttribute( 'typeof' ) || '' ).indexOf( 'mw:ExpandedAttrs' ) !== -1
};
this.setClassAttributes( attributes, classAttr );
if ( !ve.isEmptyObject( attributes ) ) {
dataElement.attributes = attributes;
}
dataElement.attributes = attributes;
return dataElement;
};

View file

@ -820,6 +820,7 @@ ve.dm.mwExample.domToDataCases = {
{
type: 'mwTable',
attributes: {
hasExpandedAttrs: false,
wikitable: true,
sortable: true,
originalClasses: 'wikitable sortable wikitable',

View file

@ -90,12 +90,16 @@ ve.ui.MWTableDialog.prototype.getSetupProcess = function ( data ) {
sortable = !!tableNode.getAttribute( 'sortable' ),
collapsible = !!tableNode.getAttribute( 'collapsible' ),
collapsed = !!tableNode.getAttribute( 'collapsed' ),
hasExpandedAttrs = !!tableNode.getAttribute( 'hasExpandedAttrs' ),
isReadOnly = this.isReadOnly();
this.wikitableToggle.setValue( wikitable ).setDisabled( isReadOnly );
this.sortableToggle.setValue( sortable ).setDisabled( isReadOnly );
this.collapsibleToggle.setValue( collapsible ).setDisabled( isReadOnly );
this.collapsedToggle.setValue( collapsed ).setDisabled( isReadOnly );
// These toggles are disabled if hasExpandedAttrs, but the inherited "Caption"
// toggle will still work, as it isn't a real table node property.
// TODO: Show a message explaining why these toggles are disabled.
this.wikitableToggle.setValue( wikitable ).setDisabled( isReadOnly || hasExpandedAttrs );
this.sortableToggle.setValue( sortable ).setDisabled( isReadOnly || hasExpandedAttrs );
this.collapsibleToggle.setValue( collapsible ).setDisabled( isReadOnly || hasExpandedAttrs );
this.collapsedToggle.setValue( collapsed ).setDisabled( isReadOnly || hasExpandedAttrs );
ve.extendObject( this.initialValues, {
wikitable: wikitable,