-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #115 from lowercasename/rk/typescript
Typescript migration project (event group linker)
- Loading branch information
Showing
10 changed files
with
257 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
function eventGroupLinker() { | ||
return { | ||
data: { | ||
eventGroupID: "", | ||
eventGroupEditToken: "", | ||
groups: [], | ||
}, | ||
async init() { | ||
this.$watch("data.eventGroupID", () => { | ||
this.$dispatch( | ||
"event-group-id-changed", | ||
this.data.eventGroupID, | ||
); | ||
}); | ||
this.$watch("data.eventGroupEditToken", () => { | ||
this.$dispatch( | ||
"event-group-edit-token-changed", | ||
this.data.eventGroupEditToken, | ||
); | ||
}); | ||
if (window.eventData && window.eventData.eventGroupID !== "") { | ||
this.data.eventGroupID = window.eventData.eventGroupID; | ||
} | ||
if (window.eventData && window.eventGroupEditToken !== "") { | ||
this.data.eventGroupEditToken = | ||
window.eventData.eventGroupEditToken; | ||
} | ||
try { | ||
const editTokens = JSON.parse( | ||
localStorage.getItem("editTokens"), | ||
); | ||
if (!editTokens) { | ||
return; | ||
} | ||
const response = await fetch("/known/groups", { | ||
method: "POST", | ||
body: JSON.stringify(editTokens), | ||
headers: { | ||
"Content-Type": "application/json", | ||
}, | ||
}); | ||
if (!response.ok) { | ||
return; | ||
} | ||
const json = await (await response).json(); | ||
this.data.groups = json; | ||
} catch (e) { | ||
return false; | ||
} | ||
}, | ||
selectGroup(e) { | ||
const group = this.data.groups.find( | ||
(group) => group.id === e.target.value, | ||
); | ||
if (!group) { | ||
this.data.eventGroupID = ""; | ||
this.data.eventGroupEditToken = ""; | ||
return; | ||
} | ||
this.data.eventGroupID = group.id; | ||
this.data.eventGroupEditToken = group.editToken; | ||
}, | ||
showGroupPreview() { | ||
return ( | ||
this.data.eventGroupID !== "" && | ||
this.data.groups.some( | ||
(group) => | ||
group.id === this.data.eventGroupID && | ||
group.editToken === this.data.eventGroupEditToken, | ||
) | ||
); | ||
}, | ||
groupPreview() { | ||
if (!this.showGroupPreview()) { | ||
return {}; | ||
} | ||
return this.data.groups.find( | ||
(group) => group.id === this.data.eventGroupID, | ||
); | ||
}, | ||
resetGroupSelector() { | ||
this.$refs.eventGroupSelect.value = ""; | ||
}, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters