-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#212 Move some files around for cohesion
- Loading branch information
1 parent
40d78cb
commit ce88e0f
Showing
5 changed files
with
73 additions
and
65 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
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
56 changes: 56 additions & 0 deletions
56
src/ts/content/extensions/util/tagValidation/dialogs/userAcceptance.ts
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,56 @@ | ||
import {createModal} from "../../../../../common/ui/modal"; | ||
import {UIColour} from "../../../../../common/ui/colour"; | ||
import {insertTags} from "./insertTags"; | ||
import {getSheetLink} from "../../../../../common/entities/spreadsheet"; | ||
import {GetTagsOptions} from "../types"; | ||
|
||
const getUserAcceptance = ( | ||
invalidTags: string[], | ||
saveHandler: (options: GetTagsOptions) => Promise<boolean> | ||
): Promise<boolean> => | ||
new Promise<boolean>((resolve) => | ||
createModal({ | ||
text: "Are you sure? The following tags are not in the Tag Index", | ||
subText: invalidTags, | ||
elements: [ | ||
{ | ||
kind: "button", | ||
text: "Open the Tag Index", | ||
colour: UIColour.GREY, | ||
onClick: async () => resolve(getSecondaryAcceptance(saveHandler)), | ||
}, | ||
{ | ||
kind: "button", | ||
text: "Insert Tags", | ||
colour: UIColour.GREY, | ||
onClick: async () => resolve(insertTags(invalidTags).then(() => saveHandler({noCache: true}))), | ||
}, | ||
{kind: "button", text: "Save anyway", colour: UIColour.GREY, onClick: async () => resolve(true)}, | ||
{kind: "button", text: "Cancel", colour: UIColour.PURPLE, onClick: async () => resolve(false)}, | ||
], | ||
colour: UIColour.PURPLE, | ||
onCancel: async () => resolve(false), | ||
}) | ||
); | ||
|
||
const getSecondaryAcceptance = async (saveHandler: (options: GetTagsOptions) => Promise<boolean>): Promise<boolean> => { | ||
window.open(await getSheetLink()); | ||
return new Promise<boolean>((resolve) => | ||
createModal({ | ||
text: "Did you put the new tags in the Tag Index?", | ||
elements: [ | ||
{ | ||
kind: "button", | ||
text: "Yes!", | ||
colour: UIColour.GREY, | ||
onClick: async () => resolve(saveHandler({noCache: true})), | ||
}, | ||
{kind: "button", text: "Cancel", colour: UIColour.PURPLE, onClick: async () => resolve(false)}, | ||
], | ||
colour: UIColour.PURPLE, | ||
onCancel: async () => resolve(false), | ||
}) | ||
); | ||
}; | ||
|
||
export {getUserAcceptance}; |
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,3 @@ | ||
import {appendTagValidator} from "./appendTagValidator"; | ||
|
||
export {appendTagValidator}; |
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,3 @@ | ||
type GetTagsOptions = {noCache: boolean}; | ||
|
||
export type {GetTagsOptions}; |