Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- return {
- plots: Utilities.instance.plots,
- groups: groups,
- selectedPlots: Utilities.instance.getSelected(),
- selectedPlotsName: "",
- selectedGroups: selectedGroups,
- selectedGroupsName: "",
- selectedGroupIDs: selectedGroupIDs
- }
- },
- methods: {
- change(type: string, field: string, fieldValue: string, oldSelected: any) {
- const selected = this.selectedPlots[type]
- const plots = this.plots[type]
- for (const group_id of this.selectedGroupIDs) {
- let otherField = "page"
- if (field === otherField) {
- otherField = "kind"
- }
- const add = oldSelected[type][field].includes(fieldValue)
- if (selected[otherField].length === 0 && add && plots[otherField].length === 1) {
- selected[otherField].push(plots[otherField][0])
- }
- for (const otherFieldValue of selected[otherField]) {
- let request: Request
- if (otherField === "page") {
- request = new Request(Number(group_id), type, otherFieldValue, fieldValue)
- } else {
- request = new Request(Number(group_id), type, fieldValue, otherFieldValue)
- }
- if (add) {
- this.addPlot(request)
- } else {
- this.removePlot(request)
- }
- }
- if (selected[field].length === 0 && plots[field].length === 1) {
- selected[otherField] = []
- }
- }
- },
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement