Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- data: function() {
- const groups: Group[] = []
- const selectedGroups: number[] = []
- return {
- plots: Utilities.instance.plots,
- groups: groups,
- plotSet: new Set<PlotProvider>(), //todo delete it
- groupSet: new Set<number>(),
- selectedPlots: Utilities.instance.getSelected(),
- selectedPlotsName: "",
- selectedGroups: selectedGroups,
- selectedGroupsName: ""
- }
- },
- methods: {
- setPlot(type: string, field: string, fieldValue: string, oldSelected: Plots): void {
- const selected = this.selectedPlots[type]
- const plots = this.plots[type]
- console.log("set")
- console.log(this.groupSet)
- this.groupSet.forEach(group_id => {
- console.log("PROCESSING " + type + " " + field + " " + fieldValue + " " + group_id)
- const otherField = (
- field === "page" ?
- "kind" : "page"
- )
- let add = false
- this.plotSet.forEach(value => {
- add = !(value.type === type && value[field] === fieldValue && value[otherField] === otherFieldValue && value.group_id === group_id)
- })// add stays here
- for (const otherFieldValue of selected[otherField]) {
- console.log("FOR " + type + " " + field + " " + fieldValue + " " + group_id + " " + otherField + " " + otherFieldValue)
- const provider = (
- otherField === "page" ?
- new PlotProvider(Number(group_id), type, otherFieldValue, fieldValue)
- :
- new PlotProvider(Number(group_id), type, fieldValue, otherFieldValue)
- )
- //todo refactor
- if (selected[otherField].length === 0 && add && plots[otherField].length === 1) {
- selected[otherField].push(plots[otherField][0])
- }
- if (add) {
- this.plotSet.add(provider)
- } else {
- this.plotSet.delete(provider)
- }
- }
- if (selected[field].length === 0 && plots[field].length === 1) {
- selected[otherField] = []
- }
- })
- },
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement