Show planned sequences in status field of preplots table.

Closes #86.
This commit is contained in:
D. Berge
2021-05-09 00:20:02 +02:00
parent df9f7f33cf
commit 788c582f98
2 changed files with 51 additions and 14 deletions

View File

@@ -46,6 +46,8 @@
background-color green
&.online
background-color blue
&.planned
background-color magenta
</style>
<script>
@@ -96,6 +98,8 @@ export default {
? "Acquired"
: s.status == "ntbp"
? "NTBP"
: s.status == "planned"
? "Planned"
: s.status;
const remarks = "\n"+[s.remarks, s.remarks_final].join("\n").trim()

View File

@@ -28,9 +28,12 @@
<v-list-item-title v-if="contextMenuItem.ntba">Unset NTBA</v-list-item-title>
<v-list-item-title v-else>Set NTBA</v-list-item-title>
</v-list-item>
<v-list-item @click="addToPlan" v-if="!contextMenuItem.ntba">
<v-list-item @click="addToPlan" v-if="!contextMenuItem.ntba && !isPlanned(contextMenuItem)">
<v-list-item-title>Add to plan</v-list-item-title>
</v-list-item>
<v-list-item @click="removeFromPlan" v-if="isPlanned(contextMenuItem)">
<v-list-item-title>Remove from plan</v-list-item-title>
</v-list-item>
</v-list>
</v-menu>
@@ -205,7 +208,8 @@ export default {
},
async serverEvent (event) {
if (event.channel == "preplot_lines" && event.payload.pid == this.$route.params.project) {
if (event.payload.pid == this.$route.params.project) {
if (event.channel == "preplot_lines") {
if (!this.loading && !this.queuedReload) {
// Do not force a non-cached response if refreshing as a result
// of an event notification. We will assume that the server has
@@ -215,18 +219,27 @@ export default {
} else {
this.queuedReload = true;
}
} else if ([ "planned_lines", "raw_lines", "final_lines" ].includes(event.channel)) {
if (!this.loading && !this.queuedReload) {
this.getSequences();
} else {
this.queuedReload = true;
}
}
}
},
queuedReload (newVal, oldVal) {
if (newVal && !oldVal && !this.loading) {
this.getLines();
this.getSequences();
}
},
loading (newVal, oldVal) {
if (!newVal && oldVal && this.queuedReload) {
this.getLines();
this.getSequences();
}
},
@@ -242,6 +255,10 @@ export default {
methods: {
isPlanned(item) {
return this.sequences.find(i => i.line == item.line && i.status == 'planned');
},
contextMenu (e, {item}) {
e.preventDefault();
this.contextMenuShow = false;
@@ -252,6 +269,7 @@ export default {
},
setNTBA () {
this.removeFromPlan();
this.saveItem({
line: this.contextMenuItem.line,
key: 'ntba',
@@ -266,7 +284,6 @@ export default {
fsp: this.contextMenuItem.fsp,
lsp: this.contextMenuItem.lsp
}
console.log("Plan", payload);
const url = `/project/${this.$route.params.project}/plan`;
const init = {
method: "POST",
@@ -276,6 +293,17 @@ export default {
await this.api([url, init]);
},
async removeFromPlan () {
const plannedLine = this.sequences.find(i => i.status == "planned" && i.line == this.contextMenuItem.line);
if (plannedLine && plannedLine.sequence) {
const url = `/project/${this.$route.params.project}/plan/${plannedLine.sequence}`;
const init = {
method: "DELETE"
}
await this.api([url, init]);
}
},
editItem (item, key) {
this.edit = {
line: item.line,
@@ -319,8 +347,13 @@ export default {
},
async getSequences () {
const url = `/project/${this.$route.params.project}/sequence`;
this.sequences = await this.api([url]) || [];
const urlS = `/project/${this.$route.params.project}/sequence`;
this.sequences = await this.api([urlS]) || [];
const urlP = `/project/${this.$route.params.project}/plan`;
const planned = await this.api([urlP]) || [];
planned.forEach(i => i.status = "planned");
this.sequences.push(...planned);
},
setActiveItem (item) {