Skip to content

Commit

Permalink
admin: Register common components as global
Browse files Browse the repository at this point in the history
  • Loading branch information
somnisomni committed Dec 18, 2024
1 parent e71a35b commit 64f0b4d
Show file tree
Hide file tree
Showing 15 changed files with 27 additions and 44 deletions.
6 changes: 4 additions & 2 deletions projects/Admin/src/components/common/FileInputButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
</template>

<script lang="ts">
import { Component, Emit, Model, Prop, Ref, Vue } from "vue-facing-decorator";
import { Component, Emit, Model, Prop, Ref, toNative, Vue } from "vue-facing-decorator";
import { MAX_UPLOAD_FILE_BYTES } from "@myboothmanager/common";
import { useAdminStore } from "@/plugins/stores/admin";
Expand All @@ -40,7 +40,7 @@ const ACCEPTS_MIMES: Record<FileInputAccepts, Array<string>> = {
@Component({
emits: ["change"],
})
export default class FileInputButton extends Vue {
export class FileInputButton extends Vue {
@Model({ type: File, default: null }) value!: File | null;
@Prop({ type: String, default: "파일 선택" }) label!: string;
@Prop({ type: Boolean, default: false }) disabled!: boolean;
Expand Down Expand Up @@ -118,4 +118,6 @@ export default class FileInputButton extends Vue {
this.$forceUpdate();
}
}
export default toNative(FileInputButton);
</script>
11 changes: 5 additions & 6 deletions projects/Admin/src/components/common/ImageWithUpload.vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,14 @@
</template>

<script lang="ts">
import { Component, Prop, Vue } from "vue-facing-decorator";
import { Component, Prop, toNative, Vue } from "vue-facing-decorator";
import { getUploadFileUrl } from "@/lib/functions";
import FileInputButton, { FileInputAccepts } from "./FileInputButton.vue";
import { FileInputAccepts } from "./FileInputButton.vue";
@Component({
emits: ["updated", "error"],
components: {
FileInputButton,
},
})
export default class ImageWithUpload extends Vue {
export class ImageWithUpload extends Vue {
readonly FileInputAccepts = FileInputAccepts;
@Prop({ type: String, required: true, default: null }) existingSrc!: string | null;
Expand Down Expand Up @@ -127,4 +124,6 @@ export default class ImageWithUpload extends Vue {
return this.imageFilePickedObjectURL ?? getUploadFileUrl(this.existingSrc);
}
}
export default toNative(ImageWithUpload);
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ const useProxyStore = defineStore("BoothManageDialog__proxy", () => {
@Component({
components: {
CommonForm,
FormDataLossWarningDialog,
},
emits: ["updated", "error"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,11 @@ import { ErrorCodes, type IBoothMember, type IBoothMemberCreateRequest, type IBo
import { useAdminStore } from "@/plugins/stores/admin";
import { useAdminAPIStore } from "@/plugins/stores/api";
import { CommonForm, FormFieldType, type FormFieldOptions } from "../common/CommonForm.vue";
import ImageWithUpload from "../common/ImageWithUpload.vue";
import FormDataLossWarningDialog from "./common/FormDataLossWarningDialog.vue";
import ItemDeleteWarningDialog from "./common/ItemDeleteWarningDialog.vue";
@Component({
components: {
ImageWithUpload,
CommonForm,
FormDataLossWarningDialog,
ItemDeleteWarningDialog,
},
Expand Down
1 change: 0 additions & 1 deletion projects/Admin/src/components/dialogs/FeedbackDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ import FormDataLossWarningDialog from "./common/FormDataLossWarningDialog.vue";
@Component({
components: {
CommonForm,
FormDataLossWarningDialog,
},
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ import ItemDeleteWarningDialog from "./common/ItemDeleteWarningDialog.vue";
@Component({
components: {
CommonForm,
FormDataLossWarningDialog,
ItemDeleteWarningDialog,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,12 @@ import { reactive, readonly } from "vue";
import { useAdminStore } from "@/plugins/stores/admin";
import { useAdminAPIStore } from "@/plugins/stores/api";
import { CommonForm, FormFieldType, type FormFieldOptions } from "../common/CommonForm.vue";
import ImageWithUpload from "../common/ImageWithUpload.vue";
import FormDataLossWarningDialog from "./common/FormDataLossWarningDialog.vue";
import ItemDeleteWarningDialog from "./common/ItemDeleteWarningDialog.vue";
import GoodsSelectionDialog from "./GoodsSelectionDialog.vue";
@Component({
components: {
ImageWithUpload,
CommonForm,
GoodsSelectionDialog,
FormDataLossWarningDialog,
ItemDeleteWarningDialog,
Expand Down
3 changes: 0 additions & 3 deletions projects/Admin/src/components/dialogs/GoodsManageDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,12 @@ import { useAdminStore } from "@/plugins/stores/admin";
import FormDataLossWarningDialog from "@/components/dialogs/common/FormDataLossWarningDialog.vue";
import { useAdminAPIStore } from "@/plugins/stores/api";
import { CommonForm } from "../common/CommonForm.vue";
import ImageWithUpload from "../common/ImageWithUpload.vue";
import { FormFieldType, type FormFieldOptions } from "../common/CommonForm.vue";
import GoodsCategoryManageDialog from "./GoodsCategoryManageDialog.vue";
import ItemDeleteWarningDialog from "./common/ItemDeleteWarningDialog.vue";
@Component({
components: {
ImageWithUpload,
CommonForm,
GoodsCategoryManageDialog,
FormDataLossWarningDialog,
ItemDeleteWarningDialog,
Expand Down
2 changes: 2 additions & 0 deletions projects/Admin/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { getUploadFileUrl } from "./lib/functions";
import App from "./App.vue";
import router from "./plugins/router";
import vuetify from "./plugins/vuetify";
import commonComponents from "@/plugins/common-components";

/* *====* */

Expand All @@ -21,5 +22,6 @@ app.use(pinia);
app.use(router);
app.use(vuetify);
app.use(CommonUI, { imageUrlResolver: getUploadFileUrl });
app.use(commonComponents);

app.mount("#app");
2 changes: 0 additions & 2 deletions projects/Admin/src/pages/subpages/InfoPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,11 @@ import { Component, Vue } from "vue-facing-decorator";
import BoothInfoPanel from "@/components/info/BoothInfoPanel.vue";
import BoothMembersPanel from "@/components/info/BoothMembersPanel.vue";
import BoothNoticePanel from "@/components/info/BoothNoticePanel.vue";
import ImageWithUpload from "@/components/common/ImageWithUpload.vue";
import { useAdminStore } from "@/plugins/stores/admin";
import { useAdminAPIStore } from "@/plugins/stores/api";
@Component({
components: {
ImageWithUpload,
BoothInfoPanel,
BoothMembersPanel,
BoothNoticePanel,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,10 @@

<script lang="ts">
import { Component, toNative, Vue } from "vue-facing-decorator";
import ImageWithUpload from "@/components/common/ImageWithUpload.vue";
import { useAdminAPIStore } from "@/plugins/stores/api";
import { useAdminStore } from "@/plugins/stores/admin";
@Component({
components: {
ImageWithUpload,
},
})
@Component({})
class InfoBannerImagePage extends Vue {
get imagePath(): string | null {
return useAdminStore().currentBooth.booth!.bannerImage?.path ?? null;
Expand Down
7 changes: 1 addition & 6 deletions projects/Admin/src/pages/subpages/info/InfoInfoImagePage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,10 @@

<script lang="ts">
import { Component, toNative, Vue } from "vue-facing-decorator";
import ImageWithUpload from "@/components/common/ImageWithUpload.vue";
import { useAdminAPIStore } from "@/plugins/stores/api";
import { useAdminStore } from "@/plugins/stores/admin";
@Component({
components: {
ImageWithUpload,
},
})
@Component({})
class InfoInfoImagePage extends Vue {
get imagePath(): string | null {
return useAdminStore().currentBooth.booth!.infoImage?.path ?? null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,7 @@ import { CommonForm, type FormFieldOptions, FormFieldType } from "@/components/c
import { useAdminStore } from "@/plugins/stores/admin";
import { SuperAdminAPI } from "../SuperAdminPage.lib";
@Component({
components: {
CommonForm,
},
})
@Component({})
export default class SACreateAccountFragment extends Vue {
@Setup(() => useAdminStore().globalSnackbarContexts)
declare readonly globalSnackbarContexts: SnackbarContextWrapper;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,7 @@ import { CommonForm, FormFieldType, type FormFieldOptions } from "@/components/c
import { useAdminStore } from "@/plugins/stores/admin";
import { SuperAdminAPI } from "../SuperAdminPage.lib";
@Component({
components: {
CommonForm,
},
})
@Component({})
export default class SACreateFairFragment extends Vue {
@Setup(() => useAdminStore().globalSnackbarContexts)
declare readonly globalSnackbarContexts: SnackbarContextWrapper;
Expand Down
12 changes: 12 additions & 0 deletions projects/Admin/src/plugins/common-components.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import CommonForm from "@/components/common/CommonForm.vue";
import FileInputButton from "@/components/common/FileInputButton.vue";
import ImageWithUpload from "@/components/common/ImageWithUpload.vue";
import type { App } from "vue";

export default {
install(app: App) {
app.component("CommonForm", CommonForm);
app.component("FileInputButton", FileInputButton);
app.component("ImageWithUpload", ImageWithUpload);
},
};

0 comments on commit 64f0b4d

Please sign in to comment.