| <template> |
| <Popup v-if="renderInnerPopup" :title="infoPayload.title" v-model="openToUse" :cancelBtnTxt="cancelBtnTxt" |
| :cancelBtnClass="cancelBtnClass" :actionBtnTxt="actionBtnTxt" :actionBtnTxt2="actionBtnTxt2" |
| :actionBtnTxt3="actionBtnTxt3" :actionBtnTxt4="actionBtnTxt4" :isActionBtnEnabled="validateUserInputs" |
| :prohibitCancel="prohibitCancel" :cancelXBtn="cancelXBtn" :variant="variant" @onDone="onPopupDone" |
| @onDone2="onPopupDone2" @onDone3="onPopupDone3" @onDone4="onPopupDone4" @onClosed="onClosed" |
| @onCancel="onPopupCancel" :id="'modal-' + infoPayload.pluginId" :modalWidth="modalWidth" |
| :submitOnEnter="submitOnEnter" :styleBtn1AsCancel="styleBtn1AsCancel"> |
| |
| |
| <p v-if="infoPayload.intro !== ''" v-html="infoPayload.intro + |
| ' ' |
| + (infoPayload.details ? infoPayload.details : '') |
| "></p> |
| <span v-if="citationsTxt !== ''" v-html="citationsTxt"></span> |
| <slot></slot> |
| <FormFull ref="formfull" :id="infoPayload.pluginId" v-model="userArgsFixed" @onChange="onChange" |
| @onMolCountsChanged="onMolCountsChanged" @onRawValChange="onRawValChange" :hideIfDisabled="hideIfDisabled"> |
| </FormFull> |
| <slot name="afterForm"></slot> |
| |
| </Popup> |
| </template> |
| |
| <script lang="ts"> |
| |
| |
| import { Options, mixins } from "vue-class-component"; |
| import { Prop } from "vue-property-decorator"; |
| import { UserArg } from "@/UI/Forms/FormFull/FormFullInterfaces"; |
| import FormFull from "@/UI/Forms/FormFull/FormFull.vue"; |
| import Popup from "@/UI/MessageAlerts/Popups/Popup.vue"; |
| import { PopupMixin } from "./Mixins/PopupMixin"; |
| import { PopupVariant } from "@/UI/MessageAlerts/Popups/InterfacesAndEnums"; |
| import { |
| fixUserArgs, |
| convertMoleculeInputParamsToFileInfos, |
| } from "../UserInputUtils"; |
| import { IInfoPayload } from "@/Plugins/PluginInterfaces"; |
| import { citationsTxt } from "@/Plugins/Citations"; |
| import { logEvent } from "@/Core/Analytics"; |
| import { IProtCmpdCounts } from "@/UI/Forms/MoleculeInputParams/MoleculeInput"; |
| |
| |
| |
| |
| @Options({ |
| components: { |
| Popup, |
| FormFull, |
| }, |
| }) |
| export default class PluginComponent extends mixins(PopupMixin) { |
| /** Whether the action button (e.g., "Load") is enabled. */ |
| @Prop({ default: undefined }) isActionBtnEnabled!: boolean; |
| |
| @Prop({ default: undefined }) modalWidth!: string; |
| |
| @Prop({ required: true }) infoPayload!: IInfoPayload; |
| |
| |
| |
| |
| |
| @Prop({ default: false }) hideIfDisabled!: boolean; |
| |
| |
| @Prop({ default: "Load" }) actionBtnTxt!: string; |
| |
| |
| |
| @Prop({ default: "" }) actionBtnTxt2!: string; |
| @Prop({ default: "" }) actionBtnTxt3!: string; |
| @Prop({ default: "" }) actionBtnTxt4!: string; |
| |
| |
| |
| |
| |
| @Prop({ default: false }) prohibitCancel!: boolean; |
| |
| |
| @Prop({ default: "Cancel" }) cancelBtnTxt!: string; |
| |
| |
| |
| |
| @Prop({ default: "btn-secondary" }) cancelBtnClass!: string; |
| |
| @Prop({ default: true }) cancelXBtn!: boolean; |
| |
| |
| |
| |
| @Prop({ default: PopupVariant.Primary }) variant!: PopupVariant; |
| |
| |
| |
| |
| |
| @Prop({ default: true }) submitOnEnter!: boolean; |
| |
| |
| |
| |
| |
| |
| @Prop({ default: false }) styleBtn1AsCancel!: boolean; |
| |
| |
| |
| |
| {UserArg[]} The user arguments (i.e., plugin parameters) to use. |
| */ |
| get userArgsFixed(): UserArg[] { |
| return fixUserArgs(this.infoPayload.userArgs); |
| } |
| |
| |
| |
| |
| {UserArg[]} val The user arguments (i.e., plugin parameters). |
| */ |
| set userArgsFixed(val: UserArg[]) { |
| this.onChange(val); |
| } |
| |
| |
| |
| |
| {string} The citations as a string. |
| */ |
| get citationsTxt(): string { |
| return citationsTxt(this.infoPayload); |
| } |
| |
| |
| |
| |
| |
| {boolean} True if all userData validate. False if even one does |
| * not validate. |
| */ |
| get validateUserInputs(): boolean { |
| // If isActionBtnEnabled is defined on the plugin, it overrides any |
| // validation. |
| if (this.isActionBtnEnabled !== undefined) { |
| return this.isActionBtnEnabled; |
| } |
| |
| |
| for (const userArg of this.userArgsFixed) { |
| const _userInput = userArg; |
| if ( |
| _userInput.validateFunc !== undefined && |
| !_userInput.validateFunc(_userInput.val) |
| ) { |
| // Doesn't validate. |
| return false; |
| } |
| } |
| |
| return true; |
| } |
| |
| |
| |
| |
| |
| {IProtCmpdCounts} val The molecule counts. |
| */ |
| onMolCountsChanged(val: IProtCmpdCounts) { |
| // Runs when the molecule counts change. |
| this.$emit("onMolCountsChanged", val); |
| } |
| |
| |
| |
| |
| |
| {string} id The ID of the user argument. |
| * @param {string} val The new value for the user argument. |
| */ |
| onRawValChange(id: string, val: string) { |
| this.$emit("onRawValChange", id, val); |
| } |
| |
| |
| |
| |
| onPopupCancel() { |
| // Log plugin started |
| if (this.infoPayload.logAnalytics !== false) { |
| logEvent(this.infoPayload.pluginId, "cancelled"); |
| } |
| |
| this.$emit("update:modelValue", false); |
| this.$emit("onPopupCancel"); |
| } |
| |
| |
| |
| |
| async onPopupDone() { |
| // Close the popup |
| this.$emit("update:modelValue", false); |
| // this.closePopup(); |
| |
| // eslint-disable-next-line @typescript-eslint/ban-ts-comment |
| // @ts-ignore |
| await convertMoleculeInputParamsToFileInfos(this.infoPayload.userArgs); |
| |
| this.$emit("onPopupDone"); |
| } |
| |
| |
| |
| |
| onPopupDone2() { |
| // this.$emit("update:modelValue", false); |
| |
| /** |
| * Runs when the secondary action button is pressed, after the popup closes. |
| */ |
| this.$emit("onPopupDone2"); |
| } |
| |
| |
| |
| |
| onPopupDone3() { |
| // this.$emit("update:modelValue", false); |
| this.$emit("onPopupDone3"); |
| } |
| |
| |
| |
| |
| onPopupDone4() { |
| // this.$emit("update:modelValue", false); |
| this.$emit("onPopupDone4"); |
| } |
| |
| |
| |
| |
| {UserArg[]} userArgsFixed The user arguments (i.e., plugin |
| * parameters). |
| */ |
| onChange(userArgsFixed: UserArg[]) { |
| // Runs when the user changes any user arguments (plugin parameters). |
| this.$emit("onUserArgChanged", this.userArgsFixed); |
| } |
| |
| |
| |
| { |
| // this.setUserInputsToUse(this.userArgs); |
| // } |
| |
| /** |
| * Plugins mounted function. |
| */ |
| mounted() { |
| // this.setUserInputsToUse(this.userArgs); |
| this.openToUse = this.modelValue; |
| } |
| } |
| </script> |
| |
| |
| <style lang="scss"></style> |
| |