mirror of
https://gitlab.com/wgp/dougal/software.git
synced 2025-12-06 08:57:08 +00:00
Compare commits
3 Commits
61-user-au
...
v1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
77258b12e9 | ||
|
|
6896d8bc87 | ||
|
|
80b463fbb7 |
@@ -58,6 +58,11 @@
|
|||||||
single-line
|
single-line
|
||||||
>
|
>
|
||||||
</v-text-field>
|
</v-text-field>
|
||||||
|
<v-checkbox
|
||||||
|
v-model="shiftAll"
|
||||||
|
class="mt-0"
|
||||||
|
label="Shift all planned sequences"
|
||||||
|
></v-checkbox>
|
||||||
</template>
|
</template>
|
||||||
</v-edit-dialog>
|
</v-edit-dialog>
|
||||||
</template>
|
</template>
|
||||||
@@ -320,6 +325,7 @@ export default {
|
|||||||
queuedReload: false,
|
queuedReload: false,
|
||||||
|
|
||||||
plannerConfig: null,
|
plannerConfig: null,
|
||||||
|
shiftAll: false, // Shift all sequences checkbox
|
||||||
|
|
||||||
// Context menu stuff
|
// Context menu stuff
|
||||||
contextMenuShow: false,
|
contextMenuShow: false,
|
||||||
@@ -355,7 +361,11 @@ export default {
|
|||||||
await this.shiftTimesAfter(item, delta);
|
await this.shiftTimesAfter(item, delta);
|
||||||
await this.saveItem({sequence: item.sequence, key: 'ts1', value: ts1});
|
await this.saveItem({sequence: item.sequence, key: 'ts1', value: ts1});
|
||||||
} else if (oldVal.key == "sequence") {
|
} else if (oldVal.key == "sequence") {
|
||||||
await this.shiftSequences(oldVal.value-item.sequence);
|
if (this.shiftAll) {
|
||||||
|
await this.shiftSequences(oldVal.value-item.sequence);
|
||||||
|
} else {
|
||||||
|
await this.shiftSequence(item, oldVal.value);
|
||||||
|
}
|
||||||
} else if (item[oldVal.key] != oldVal.value) {
|
} else if (item[oldVal.key] != oldVal.value) {
|
||||||
if (await this.saveItem(oldVal)) {
|
if (await this.saveItem(oldVal)) {
|
||||||
item[oldVal.key] = oldVal.value;
|
item[oldVal.key] = oldVal.value;
|
||||||
@@ -449,6 +459,38 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
async shiftSequence (item, newSequence) {
|
||||||
|
|
||||||
|
if (item.sequence == newSequence) {
|
||||||
|
// Nothing to do
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const conflict = this.items.find(i => i.sequence == newSequence)
|
||||||
|
if (conflict) {
|
||||||
|
this.showSnack([`Sequence ${newSequence} already exists`, "error"]);
|
||||||
|
} else {
|
||||||
|
// Cannot do this check at the moment as we would have to load the list of sequences.
|
||||||
|
// TODO We will do this after refactoring.
|
||||||
|
/*
|
||||||
|
if (this.sequences.find(i => i.sequence == newSequence)) {
|
||||||
|
this.showSnack([`Sequence ${newSequence} conflicts with a line that's already been acquired`, "warning"]);
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
const url = `/project/${this.$route.params.project}/plan/${item.sequence}`;
|
||||||
|
const init = {
|
||||||
|
method: "PATCH",
|
||||||
|
headers: {"Content-Type": "application/json"},
|
||||||
|
body: {
|
||||||
|
sequence: newSequence,
|
||||||
|
name: null
|
||||||
|
} // Setting name to null causes it to be regenerated
|
||||||
|
}
|
||||||
|
await this.api([url, init]);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
async shiftTimesAfter(item, delta) {
|
async shiftTimesAfter(item, delta) {
|
||||||
const pos = this.items.indexOf(item)+1;
|
const pos = this.items.indexOf(item)+1;
|
||||||
if (pos != 0) {
|
if (pos != 0) {
|
||||||
@@ -546,7 +588,7 @@ export default {
|
|||||||
: item;
|
: item;
|
||||||
},
|
},
|
||||||
|
|
||||||
...mapActions(["api"])
|
...mapActions(["api", "showSnack"])
|
||||||
},
|
},
|
||||||
|
|
||||||
async mounted () {
|
async mounted () {
|
||||||
|
|||||||
@@ -19,14 +19,20 @@ async function getDistance (client, payload) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function getSequence (client) {
|
async function getSequence (client) {
|
||||||
|
// Get the next free sequence from planned data
|
||||||
|
// if there is any planned lines, if not get the
|
||||||
|
// next available from raw lines
|
||||||
const text = `
|
const text = `
|
||||||
SELECT max(sequence)+1 AS sequence
|
WITH p AS (
|
||||||
FROM (
|
SELECT max(sequence) AS sequence
|
||||||
SELECT sequence
|
FROM planned_lines
|
||||||
FROM raw_lines
|
),
|
||||||
UNION SELECT sequence
|
r AS (
|
||||||
FROM planned_lines
|
SELECT max(sequence) AS sequence
|
||||||
) t;
|
FROM raw_lines
|
||||||
|
)
|
||||||
|
SELECT COALESCE(p.sequence, r.sequence)+1 AS sequence
|
||||||
|
FROM p, r;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const res = await client.query(text);
|
const res = await client.query(text);
|
||||||
|
|||||||
Reference in New Issue
Block a user