Skip to content

Commit

Permalink
Add "Create" new history button to histories grid
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmedhamidawan committed Jul 25, 2024
1 parent 423c371 commit 5c10a2c
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 6 deletions.
19 changes: 15 additions & 4 deletions client/src/components/Grid/GridHistory.vue
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
<script setup lang="ts">
import { library } from "@fortawesome/fontawesome-svg-core";
import { faPlus } from "@fortawesome/free-solid-svg-icons";
import { faPlus, faUpload } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/vue-fontawesome";
import { BNav, BNavItem } from "bootstrap-vue";
import historiesGridConfig from "@/components/Grid/configs/histories";
import historiesPublishedGridConfig from "@/components/Grid/configs/historiesPublished";
import historiesSharedGridConfig from "@/components/Grid/configs/historiesShared";
import { useHistoryStore } from "@/stores/historyStore";
import { useUserStore } from "@/stores/userStore";
import Heading from "@/components/Common/Heading.vue";
Expand All @@ -14,8 +16,9 @@ import GridList from "@/components/Grid/GridList.vue";
import HistoryArchive from "@/components/History/Archiving/HistoryArchive.vue";
const userStore = useUserStore();
const historyStore = useHistoryStore();
library.add(faPlus);
library.add(faPlus, faUpload);
interface Props {
activeList?: "archived" | "my" | "shared" | "published";
Expand All @@ -33,13 +36,21 @@ const props = withDefaults(defineProps<Props>(), {
<div class="d-flex">
<Heading h1 separator inline size="xl" class="flex-grow-1 mb-2">Histories</Heading>
<div v-if="!userStore.isAnonymous">
<BButton
size="sm"
variant="outline-primary"
data-description="grid action create new history"
@click="historyStore.createNewHistory()">
<FontAwesomeIcon :icon="faPlus" />
<span v-localize>Create</span>
</BButton>
<BButton
size="sm"
variant="outline-primary"
to="/histories/import"
data-description="grid action import new history">
<Icon :icon="faPlus" />
<span v-localize>Import History</span>
<FontAwesomeIcon :icon="faUpload" />
<span v-localize>Import</span>
</BButton>
</div>
</div>
Expand Down
3 changes: 2 additions & 1 deletion client/src/components/Grid/GridPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ interface Props {
const props = withDefaults(defineProps<Props>(), {
activeList: "my",
username: undefined,
});
</script>

Expand All @@ -32,7 +33,7 @@ const props = withDefaults(defineProps<Props>(), {
<div v-if="!userStore.isAnonymous">
<BButton id="page-create" size="sm" variant="outline-primary" to="/pages/create">
<Icon :icon="faPlus" />
<span v-localize>Create Page</span>
<span v-localize>Create</span>
</BButton>
</div>
</div>
Expand Down
11 changes: 10 additions & 1 deletion client/src/components/Grid/configs/histories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
faSignature,
faTrash,
faTrashRestore,
faUpload,
faUsers,
} from "@fortawesome/free-solid-svg-icons";
import { useEventBus } from "@vueuse/core";
Expand Down Expand Up @@ -52,8 +53,16 @@ async function getData(offset: number, limit: number, search: string, sort_by: s
*/
const actions: ActionArray = [
{
title: "Import New History",
title: "Create",
icon: faPlus,
handler: () => {
const historyStore = useHistoryStore();
historyStore.createNewHistory();
},
},
{
title: "Import",
icon: faUpload,
handler: () => {
emit("/histories/import");
},
Expand Down

0 comments on commit 5c10a2c

Please sign in to comment.