mirror of
https://github.com/nasa/openmct.git
synced 2024-12-21 22:17:49 +00:00
Show edit only if view is editable. Rename editable to canEdit
This commit is contained in:
parent
c0b7276787
commit
d026bc2134
@ -41,6 +41,7 @@ define(
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
EditActionPolicy.prototype.countEditableViews = function (context) {
|
EditActionPolicy.prototype.countEditableViews = function (context) {
|
||||||
|
console.trace('countEditableViews');
|
||||||
var domainObject = context.domainObject,
|
var domainObject = context.domainObject,
|
||||||
count = 0,
|
count = 0,
|
||||||
type, views;
|
type, views;
|
||||||
@ -65,10 +66,10 @@ define(
|
|||||||
});
|
});
|
||||||
|
|
||||||
function isEditable(view) {
|
function isEditable(view) {
|
||||||
if (typeof view.editable === Function) {
|
if (typeof view.canEdit === Function) {
|
||||||
return view.editable(domainObject.useCapability('adapter'));
|
return view.canEdit(domainObject.useCapability('adapter'));
|
||||||
} else {
|
} else {
|
||||||
return view.editable === true;
|
return view.canEdit === true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,7 +21,9 @@ define([
|
|||||||
name: legacyView.name,
|
name: legacyView.name,
|
||||||
cssClass: legacyView.cssClass,
|
cssClass: legacyView.cssClass,
|
||||||
description: legacyView.description,
|
description: legacyView.description,
|
||||||
editable: legacyView.editable,
|
canEdit: function () {
|
||||||
|
return legacyView.editable === true;
|
||||||
|
},
|
||||||
canView: function (domainObject) {
|
canView: function (domainObject) {
|
||||||
if (!domainObject || !domainObject.identifier) {
|
if (!domainObject || !domainObject.identifier) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -33,6 +33,9 @@ export default function () {
|
|||||||
canView: function (domainObject) {
|
canView: function (domainObject) {
|
||||||
return domainObject.type === 'layout';
|
return domainObject.type === 'layout';
|
||||||
},
|
},
|
||||||
|
canEdit: function (domainObject) {
|
||||||
|
return domainObject.type === 'layout';
|
||||||
|
},
|
||||||
view: function (domainObject) {
|
view: function (domainObject) {
|
||||||
let component;
|
let component;
|
||||||
return {
|
return {
|
||||||
|
@ -35,6 +35,9 @@ define([
|
|||||||
canView: function (domainObject) {
|
canView: function (domainObject) {
|
||||||
return domainObject.type === 'flexible-layout';
|
return domainObject.type === 'flexible-layout';
|
||||||
},
|
},
|
||||||
|
canEdit: function (domainObject) {
|
||||||
|
return domainObject.type === 'flexible-layout';
|
||||||
|
},
|
||||||
view: function (domainObject) {
|
view: function (domainObject) {
|
||||||
let component;
|
let component;
|
||||||
|
|
||||||
|
@ -20,6 +20,9 @@ define([
|
|||||||
canView: function (domainObject) {
|
canView: function (domainObject) {
|
||||||
return domainObject.type === 'summary-widget';
|
return domainObject.type === 'summary-widget';
|
||||||
},
|
},
|
||||||
|
canEdit: function (domainObject) {
|
||||||
|
return domainObject.type === 'summary-widget';
|
||||||
|
},
|
||||||
view: function (domainObject) {
|
view: function (domainObject) {
|
||||||
var statusService = openmct.$injector.get('statusService');
|
var statusService = openmct.$injector.get('statusService');
|
||||||
var objectId = objectUtils.makeKeyString(domainObject.identifier);
|
var objectId = objectUtils.makeKeyString(domainObject.identifier);
|
||||||
@ -32,7 +35,6 @@ define([
|
|||||||
return new SummaryWidgetView(domainObject, openmct);
|
return new SummaryWidgetView(domainObject, openmct);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
editable: true,
|
|
||||||
priority: function (domainObject) {
|
priority: function (domainObject) {
|
||||||
if (domainObject.type === 'summary-widget') {
|
if (domainObject.type === 'summary-widget') {
|
||||||
return Number.MAX_VALUE;
|
return Number.MAX_VALUE;
|
||||||
|
@ -35,6 +35,9 @@ define([
|
|||||||
canView: function (domainObject) {
|
canView: function (domainObject) {
|
||||||
return domainObject.type === 'tabs';
|
return domainObject.type === 'tabs';
|
||||||
},
|
},
|
||||||
|
canEdit: function (domainObject) {
|
||||||
|
return domainObject.type === 'tabs';
|
||||||
|
},
|
||||||
view: function (domainObject) {
|
view: function (domainObject) {
|
||||||
let component;
|
let component;
|
||||||
|
|
||||||
|
@ -36,13 +36,13 @@ define([
|
|||||||
key: 'table',
|
key: 'table',
|
||||||
name: 'Telemetry Table',
|
name: 'Telemetry Table',
|
||||||
cssClass: 'icon-tabular-realtime',
|
cssClass: 'icon-tabular-realtime',
|
||||||
editable: function(domainObject) {
|
canView(domainObject) {
|
||||||
return domainObject.type === 'table';
|
|
||||||
},
|
|
||||||
canView: function (domainObject) {
|
|
||||||
return domainObject.type === 'table' || domainObject.hasOwnProperty('telemetry');
|
return domainObject.type === 'table' || domainObject.hasOwnProperty('telemetry');
|
||||||
},
|
},
|
||||||
view: function (domainObject) {
|
canEdit(domainObject) {
|
||||||
|
return domainObject.type === 'table';
|
||||||
|
},
|
||||||
|
view(domainObject) {
|
||||||
let csvExporter = new CSVExporter.default();
|
let csvExporter = new CSVExporter.default();
|
||||||
let table = new TelemetryTable(domainObject, openmct);
|
let table = new TelemetryTable(domainObject, openmct);
|
||||||
let component;
|
let component;
|
||||||
@ -67,7 +67,7 @@ define([
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
priority: function () {
|
priority() {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,7 @@
|
|||||||
<!-- Action buttons -->
|
<!-- Action buttons -->
|
||||||
<div class="l-browse-bar__actions">
|
<div class="l-browse-bar__actions">
|
||||||
<button class="l-browse-bar__actions__edit c-button icon-notebook" title="New Notebook entry"></button>
|
<button class="l-browse-bar__actions__edit c-button icon-notebook" title="New Notebook entry"></button>
|
||||||
<button class="l-browse-bar__actions__notebook-entry c-button c-button--major icon-pencil" title="Edit" v-if="!isEditing" @click="edit()"></button>
|
<button class="l-browse-bar__actions__notebook-entry c-button c-button--major icon-pencil" title="Edit" v-if="!isEditing && isViewEditable" @click="edit()"></button>
|
||||||
<button class="l-browse-bar__actions c-button c-button--major icon-save" title="Save and Finish Editing" v-if="isEditing" @click="saveAndFinishEditing()"></button>
|
<button class="l-browse-bar__actions c-button c-button--major icon-save" title="Save and Finish Editing" v-if="isEditing" @click="saveAndFinishEditing()"></button>
|
||||||
<button class="l-browse-bar__actions c-button icon-x" title="Cancel Editing" v-if="isEditing" @click="cancelEditing()"></button>
|
<button class="l-browse-bar__actions c-button icon-x" title="Cancel Editing" v-if="isEditing" @click="cancelEditing()"></button>
|
||||||
</div>
|
</div>
|
||||||
@ -119,6 +119,14 @@
|
|||||||
return {}
|
return {}
|
||||||
}
|
}
|
||||||
return objectType.definition;
|
return objectType.definition;
|
||||||
|
},
|
||||||
|
isViewEditable() {
|
||||||
|
let currentViewKey = this.currentView.key;
|
||||||
|
if (currentViewKey !== undefined) {
|
||||||
|
let currentViewProvider = this.openmct.objectViews.getByProviderKey(currentViewKey);
|
||||||
|
return currentViewProvider.canEdit && currentViewProvider.canEdit(this.domainObject);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted: function () {
|
mounted: function () {
|
||||||
|
@ -170,6 +170,18 @@ define([], function () {
|
|||||||
* otherwise 'false'.
|
* otherwise 'false'.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An optional function that defines whether or not this view can be used to edit a given object.
|
||||||
|
* If not provided, will default to `false` and the view will not support editing.
|
||||||
|
*
|
||||||
|
* @method canEdit
|
||||||
|
* @memberof module:openmct.ViewProvider#
|
||||||
|
* @param {module:openmct.DomainObject} domainObject the domain object
|
||||||
|
* to be edited
|
||||||
|
* @returns {boolean} 'true' if the view can be used to edit the provided object,
|
||||||
|
* otherwise 'false'.
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Optional method determining the priority of a given view. If this
|
* Optional method determining the priority of a given view. If this
|
||||||
* function is not defined on a view provider, then a default priority
|
* function is not defined on a view provider, then a default priority
|
||||||
|
Loading…
Reference in New Issue
Block a user