Advertisement
AndersonARC

1

Apr 21st, 2020
1,820
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. return {
  2.         plots: Utilities.instance.plots,
  3.         groups: groups,
  4.         selectedPlots: Utilities.instance.getSelected(),
  5.         selectedPlotsName: "",
  6.         selectedGroups: selectedGroups,
  7.         selectedGroupsName: "",
  8.         selectedGroupIDs: selectedGroupIDs
  9.     }
  10.   },
  11.   methods: {
  12.         change(type: string, field: string, fieldValue: string, oldSelected: any) {
  13.             const selected = this.selectedPlots[type]
  14.             const plots = this.plots[type]
  15.             for (const group_id of this.selectedGroupIDs) {
  16.                 let otherField = "page"
  17.                 if (field === otherField) {
  18.                     otherField = "kind"
  19.                 }
  20.                 const add = oldSelected[type][field].includes(fieldValue)
  21.                 if (selected[otherField].length === 0 && add && plots[otherField].length === 1) {
  22.                     selected[otherField].push(plots[otherField][0])
  23.                 }
  24.                 for (const otherFieldValue of selected[otherField]) {
  25.                     let request: Request
  26.                     if (otherField === "page") {
  27.                         request = new Request(Number(group_id), type, otherFieldValue, fieldValue)
  28.                     } else {
  29.                         request = new Request(Number(group_id), type, fieldValue, otherFieldValue)
  30.                     }
  31.                     if (add) {
  32.                         this.addPlot(request)
  33.                     } else {
  34.                         this.removePlot(request)
  35.                     }
  36.                 }
  37.                 if (selected[field].length === 0 && plots[field].length === 1) {
  38.                     selected[otherField] = []
  39.                 }
  40.             }
  41.         },
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement