Files
openmct/src/plugins/notebook/components/SectionComponent.vue
Jamie V 9fbb695379 [Restricted Notebook] Creating new Restricted Notebook type (#5173)
* added/removed status for locked, will not work with current one status per domain object setup
* setting restricted right away based on nb type
* added confirmation dialog for locking a page

* Styling for restricted Notebook
- Markup, CSS and content changes for lock button and locked message.
- Removed "Note book Type" property from NotebookType.js.
* have a version of entry template that has no listeners for locked items
* cleaning up page and section components
* making sure basic notebook stuff is installed at least once
* updating data transfer values for locked page entries, fixing page and section selection from edits
* adding locked flag to search result entries
* fixing uneditable section/page names
* cleaning up updateName function for page/section names
* removing install of restricted notebook
* updating confirmation dialog
* updating tests for new export structur
- New symbols glyph and SVG for the Shift Log. IMPORTANT: OVERRIDE ANY MERGE CONFLICTS WITH THIS COMMIT!

* made create button items dynamic each time the button is clicked, this will pick up any new types added after the create menu is created

* removing dynamic create menu list

* found a way to add the plugin before openmct.start is called
* making create items dynamic to include types added after openmct is started
* more e2e tests for restricted notebook

* updates from PR reviews, also fixed error in mct-tree thrown by not checking for an element

* plain notebook tests

* More testcase definition

* actually removing notebook object to test

* removing dupes

* checking if agent exists before relying on it... it was breaking tests with errors

* updating for new browser agent code

* fixing linting errors

Co-authored-by: Charles Hacskaylo <charlesh88@gmail.com>
Co-authored-by: unlikelyzero <jchill2@gmail.com>
Co-authored-by: John Hill <john.c.hill@nasa.gov>
Co-authored-by: Andrew Henry <akhenry@gmail.com>
Co-authored-by: Shefali Joshi <simplyrender@gmail.com>
2022-06-04 09:06:07 -07:00

133 lines
3.5 KiB
Vue

<template>
<div
class="c-list__item js-list__item"
:class="[{ 'is-selected': isSelected, 'is-notebook-default' : (defaultSectionId === section.id) }]"
:data-id="section.id"
@click="selectSection"
>
<span
class="c-list__item__name js-list__item__name"
:data-id="section.id"
contenteditable="true"
@keydown.enter="updateName"
@blur="updateName"
>{{ sectionName }}</span>
<PopupMenu
v-if="!section.isLocked"
:popup-menu-items="popupMenuItems"
/>
</div>
</template>
<script>
import PopupMenu from './PopupMenu.vue';
import RemoveDialog from '../utils/removeDialog';
export default {
components: {
PopupMenu
},
inject: ['openmct'],
props: {
defaultSectionId: {
type: String,
default() {
return '';
}
},
selectedSectionId: {
type: String,
required: true
},
section: {
type: Object,
required: true
},
sectionTitle: {
type: String,
default() {
return '';
}
}
},
data() {
return {
popupMenuItems: [],
removeActionString: `Delete ${this.sectionTitle}`
};
},
computed: {
isSelected() {
return this.selectedSectionId === this.section.id;
},
sectionName() {
return this.section.name.length ? this.section.name : `Unnamed ${this.sectionTitle}`;
}
},
mounted() {
this.addPopupMenuItems();
},
methods: {
addPopupMenuItems() {
const removeSection = {
cssClass: 'icon-trash',
name: this.removeActionString,
callback: this.getRemoveDialog.bind(this)
};
this.popupMenuItems = [removeSection];
},
deleteSection(success) {
if (!success) {
return;
}
this.$emit('deleteSection', this.section.id);
},
getRemoveDialog() {
const message = 'Other users may be editing entries in this section, and deleting it is permanent. Do you want to continue?';
const options = {
name: this.removeActionString,
callback: this.deleteSection.bind(this),
message
};
const removeDialog = new RemoveDialog(this.openmct, options);
removeDialog.show();
},
selectSection(event) {
const target = event.target;
const id = target.dataset.id;
if (!this.section.isLocked) {
const section = target.closest('.js-list__item');
const input = section.querySelector('.js-list__item__name');
if (section.className.indexOf('is-selected') > -1) {
input.classList.add('c-input-inline');
return;
}
}
if (!id) {
return;
}
this.$emit('selectSection', id);
},
updateName(event) {
const target = event.target;
target.classList.remove('c-input-inline');
const name = target.textContent.trim();
if (name === '' || this.section.name === name) {
return;
}
this.$emit('renameSection', Object.assign(this.section, { name }));
}
}
};
</script>