1
0
Fork 0
mirror of https://github.com/mealie-recipes/mealie.git synced 2025-08-05 13:35:23 +02:00

refactor(frontend): 🚧 Add group/user CRUD support for admins

This commit is contained in:
hay-kot 2021-08-06 16:28:12 -08:00
parent 917177da5b
commit 695d7e96ae
46 changed files with 2015 additions and 102 deletions

View file

@ -0,0 +1,148 @@
<template>
<div>
<BaseDialog
:title="$t('settings.backup.create-heading')"
:title-icon="$globals.icons.database"
:submit-text="$t('general.create')"
:loading="loading"
@submit="createBackup"
>
<template #open="{ open }">
<v-btn class="mx-2" small :color="color" @click="open">
<v-icon left> {{ $globals.icons.create }} </v-icon> {{ $t("general.custom") }}
</v-btn>
</template>
<v-card-text class="mt-6">
<v-text-field v-model="tag" dense :label="$t('settings.backup.backup-tag')"></v-text-field>
</v-card-text>
<v-card-actions class="mt-n9 flex-wrap">
<v-switch v-model="fullBackup" :label="switchLabel"></v-switch>
<v-spacer></v-spacer>
</v-card-actions>
<v-expand-transition>
<div v-if="!fullBackup">
<v-card-text class="mt-n4">
<v-row>
<v-col sm="4">
<p>{{ $t("general.options") }}</p>
<AdminBackupImportOptions class="mt-5" @update-options="updateOptions" />
</v-col>
<v-col>
<p>{{ $t("general.templates") }}</p>
<v-checkbox
v-for="template in availableTemplates"
:key="template"
class="mb-n4 mt-n3"
dense
:label="template"
@click="appendTemplate(template)"
></v-checkbox>
</v-col>
</v-row>
</v-card-text>
</div>
</v-expand-transition>
</BaseDialog>
</div>
</template>
<script>
import { api } from "@/api";
import AdminBackupImportOptions from "./AdminBackupImportOptions";
export default {
components: {
BaseDialog,
AdminBackupImportOptions,
},
props: {
color: {
type: String,
default: "primary",
},
},
data() {
return {
tag: null,
fullBackup: true,
loading: false,
options: {
recipes: true,
settings: true,
themes: true,
pages: true,
users: true,
groups: true,
},
availableTemplates: [],
selectedTemplates: [],
};
},
computed: {
switchLabel() {
if (this.fullBackup) {
return this.$t("settings.backup.full-backup");
} else return this.$t("settings.backup.partial-backup");
},
},
created() {
this.resetData();
this.getAvailableBackups();
},
methods: {
resetData() {
this.tag = null;
this.fullBackup = true;
this.loading = false;
this.options = {
recipes: true,
settings: true,
themes: true,
pages: true,
users: true,
groups: true,
notifications: true,
};
this.availableTemplates = [];
this.selectedTemplates = [];
},
updateOptions(options) {
this.options = options;
},
async getAvailableBackups() {
const response = await api.backups.requestAvailable();
response.templates.forEach((element) => {
this.availableTemplates.push(element);
});
},
async createBackup() {
this.loading = true;
const data = {
tag: this.tag,
options: {
recipes: this.options.recipes,
settings: this.options.settings,
pages: this.options.pages,
themes: this.options.themes,
users: this.options.users,
groups: this.options.groups,
notifications: this.options.notifications,
},
templates: this.selectedTemplates,
};
if (await api.backups.create(data)) {
this.$emit("created");
}
this.loading = false;
},
appendTemplate(templateName) {
if (this.selectedTemplates.includes(templateName)) {
const index = this.selectedTemplates.indexOf(templateName);
if (index !== -1) {
this.selectedTemplates.splice(index, 1);
}
} else this.selectedTemplates.push(templateName);
},
},
};
</script>

View file

@ -0,0 +1,118 @@
<template>
<div class="text-center">
<BaseDialog
ref="baseDialog"
:title="name"
:title-icon="$globals.icons.database"
:submit-text="$t('general.import')"
:loading="loading"
@submit="raiseEvent"
>
<v-card-subtitle v-if="date" class="mb-n3 mt-3"> {{ $d(new Date(date), "medium") }} </v-card-subtitle>
<v-divider></v-divider>
<v-card-text>
<AdminBackupImportOptions class="mt-5 mb-2" @update-options="updateOptions" />
<v-divider></v-divider>
<v-checkbox
v-model="forceImport"
dense
:label="$t('settings.remove-existing-entries-matching-imported-entries')"
></v-checkbox>
</v-card-text>
<v-divider></v-divider>
<template #extra-buttons>
<!-- <TheDownloadBtn :download-url="downloadUrl">
<template #default="{ downloadFile }">
<v-btn class="mr-1" color="info" @click="downloadFile">
<v-icon left> {{ $globals.icons.download }}</v-icon>
{{ $t("general.download") }}
</v-btn>
</template>
</TheDownloadBtn> -->
</template>
</BaseDialog>
</div>
</template>
<script>
import { api } from "@/api";
import AdminBackupImportOptions from "./AdminBackupImportOptions";
const IMPORT_EVENT = "import";
export default {
components: { AdminBackupImportOptions },
props: {
name: {
type: String,
default: "Backup Name",
},
date: {
type: String,
default: "Backup Date",
},
},
data() {
return {
loading: false,
options: {
recipes: true,
settings: true,
themes: true,
users: true,
groups: true,
},
dialog: false,
forceImport: false,
rebaseImport: false,
downloading: false,
};
},
// computed: {
// downloadUrl() {
// return API_ROUTES.backupsFileNameDownload(this.name);
// },
// },
methods: {
updateOptions(options) {
this.options = options;
},
open() {
this.dialog = true;
this.$refs.baseDialog.open();
},
close() {
this.dialog = false;
},
async raiseEvent() {
const eventData = {
name: this.name,
force: this.forceImport,
rebase: this.rebaseImport,
recipes: this.options.recipes,
settings: this.options.settings,
themes: this.options.themes,
users: this.options.users,
groups: this.options.groups,
notifications: this.options.notifications,
};
this.loading = true;
const importData = await this.importBackup(eventData);
this.$emit(IMPORT_EVENT, importData);
this.loading = false;
},
async importBackup(data) {
this.loading = true;
const response = await api.backups.import(data.name, data);
if (response) {
return response.data;
}
},
},
};
</script>
<style></style>

View file

@ -0,0 +1,69 @@
<template>
<div>
<v-checkbox
v-for="(option, index) in options"
:key="index"
v-model="option.value"
class="mb-n4 mt-n3"
dense
:label="option.text"
@change="emitValue()"
></v-checkbox>
</div>
</template>
<script>
const UPDATE_EVENT = "update-options";
export default {
data() {
return {
options: {
recipes: {
value: true,
text: this.$t("general.recipes"),
},
settings: {
value: true,
text: this.$t("general.settings"),
},
pages: {
value: true,
text: this.$t("settings.pages"),
},
themes: {
value: true,
text: this.$t("general.themes"),
},
users: {
value: true,
text: this.$t("user.users"),
},
groups: {
value: true,
text: this.$t("group.groups"),
},
notifications: {
value: true,
text: this.$t("events.notification"),
},
},
};
},
mounted() {
this.emitValue();
},
methods: {
emitValue() {
this.$emit(UPDATE_EVENT, {
recipes: this.options.recipes.value,
settings: this.options.settings.value,
themes: this.options.themes.value,
pages: this.options.pages.value,
users: this.options.users.value,
groups: this.options.groups.value,
notifications: this.options.notifications.value,
});
},
},
};
</script>

View file

@ -0,0 +1,110 @@
<template>
<div>
<ImportSummaryDialog ref="report" />
<AdminBackupImportDialog
ref="import_dialog"
:name="selectedName"
:date="selectedDate"
@import="importBackup"
@delete="deleteBackup"
/>
<BaseDialog
ref="deleteBackupConfirm"
:title="$t('settings.backup.delete-backup')"
:message="$t('general.confirm-delete-generic')"
color="error"
:icon="$globals.icons.alertCircle"
@confirm="emitDelete()"
/>
<BaseStatCard :icon="$globals.icons.backupRestore" :color="color">
<template #after-heading>
<div class="ml-auto text-right">
<h2 class="body-3 grey--text font-weight-light">
{{ $t("settings.backup-and-exports") }}
</h2>
<h3 class="display-2 font-weight-light text--primary">
<small> {{ total }}</small>
</h3>
</div>
</template>
<div class="d-flex row py-3 justify-end">
<AppButtonUpload url="/api/backups/upload" @uploaded="getAvailableBackups">
<template #default="{ isSelecting, onButtonClick }">
<v-btn :loading="isSelecting" class="mx-2" small color="info" @click="onButtonClick">
<v-icon left> {{ $globals.icons.upload }} </v-icon> {{ $t("general.upload") }}
</v-btn>
</template>
</AppButtonUpload>
<AdminBackupDialog :color="color" />
<v-btn :loading="loading" class="mx-2" small color="success" @click="createBackup">
<v-icon left> {{ $globals.icons.create }} </v-icon> {{ $t("general.create") }}
</v-btn>
</div>
<template #bottom>
<v-virtual-scroll height="290" item-height="70" :items="availableBackups">
<template #default="{ item }">
<v-list-item @click.prevent="openDialog(item, btnEvent.IMPORT_EVENT)">
<v-list-item-avatar>
<v-icon large dark :color="color">
{{ $globals.icons.database }}
</v-icon>
</v-list-item-avatar>
<v-list-item-content>
<v-list-item-title v-text="item.name"></v-list-item-title>
<v-list-item-subtitle>
{{ $d(Date.parse(item.date), "medium") }}
</v-list-item-subtitle>
</v-list-item-content>
<v-list-item-action class="ml-auto">
<v-btn large icon @click.stop="openDialog(item, btnEvent.DELETE_EVENT)">
<v-icon color="error">{{ $globals.icons.delete }}</v-icon>
</v-btn>
</v-list-item-action>
</v-list-item>
</template>
</v-virtual-scroll>
</template>
</BaseStatCard>
</div>
</template>
<script lang="ts">
import { defineComponent } from "@nuxtjs/composition-api";
import AdminBackupImportDialog from "./AdminBackupImportDialog.vue";
const IMPORT_EVENT = "import";
const DELETE_EVENT = "delete";
export default defineComponent({
components: { AdminBackupImportDialog },
layout: "admin",
setup() {
return {};
},
data() {
return {
color: "accent",
selectedName: "",
selectedDate: "",
loading: false,
events: [],
availableBackups: [],
btnEvent: { IMPORT_EVENT, DELETE_EVENT },
};
},
computed: {
total() {
return this.availableBackups.length || 0;
},
},
});
</script>
<style scoped>
</style>

View file

@ -0,0 +1,110 @@
<template>
<div>
<!-- <BaseDialog
ref="deleteEventConfirm"
:title="$t('events.delete-event')"
:message="$t('general.confirm-delete-generic')"
color="error"
:icon="$globals.icons.alertCircle"
@confirm="emitDelete()"
/> -->
<BaseStatCard :icon="$globals.icons.bellAlert" :color="color">
<template #after-heading>
<div class="ml-auto text-right">
<h2 class="body-3 grey--text font-weight-light">
{{ $t("settings.events") }}
</h2>
<h3 class="display-2 font-weight-light text--primary">
<small> {{ total }} </small>
</h3>
</div>
</template>
<div class="d-flex row py-3 justify-end">
<v-btn class="mx-2" small color="error lighten-1" @click="deleteAll">
<v-icon left> {{ $globals.icons.notificationClearAll }} </v-icon> {{ $t("general.clear") }}
</v-btn>
</div>
<template #bottom>
<v-virtual-scroll height="290" item-height="70" :items="events">
<template #default="{ item }">
<v-list-item>
<v-list-item-avatar>
<v-icon large dark :color="icons[item.category].color">
{{ icons[item.category].icon }}
</v-icon>
</v-list-item-avatar>
<v-list-item-content>
<v-list-item-title v-text="item.title"></v-list-item-title>
<v-list-item-subtitle v-text="item.text"></v-list-item-subtitle>
<v-list-item-subtitle>
{{ $d(Date.parse(item.timeStamp), "long") }}
</v-list-item-subtitle>
</v-list-item-content>
<v-list-item-action class="ml-auto">
<v-btn large icon @click="openDialog(item)">
<v-icon color="error">{{ $globals.icons.delete }}</v-icon>
</v-btn>
</v-list-item-action>
</v-list-item>
</template>
</v-virtual-scroll>
</template>
</BaseStatCard>
</div>
</template>
<script lang="ts">
import { defineComponent } from "@nuxtjs/composition-api";
export default defineComponent({
layout: "admin",
setup() {
return {};
},
data() {
return {
color: "accent",
total: 0,
selectedId: "",
events: [],
icons: {
general: {
icon: this.$globals.icons.information,
color: "info",
},
recipe: {
icon: this.$globals.icons.primary,
color: "primary",
},
backup: {
icon: this.$globals.icons.database,
color: "primary",
},
schedule: {
icon: this.$globals.icons.calendar,
color: "primary",
},
migration: {
icon: this.$globals.icons.backupRestore,
color: "primary",
},
user: {
icon: this.$globals.icons.user,
color: "accent",
},
group: {
icon: this.$globals.icons.group,
color: "accent",
},
},
};
},
});
</script>
<style scoped>
</style>

View file

@ -0,0 +1,159 @@
<template>
<BaseStatCard :icon="$globals.icons.user">
<template #avatar>
<v-avatar color="accent" size="120" class="white--text headline mt-n16">
<img
v-if="!hideImage"
:src="require(`~/static/account.png`)"
@error="hideImage = true"
@load="hideImage = false"
/>
<div v-else>
{{ initials }}
</div>
</v-avatar>
</template>
<template #after-heading>
<div class="ml-auto text-right">
<div class="body-3 grey--text font-weight-light" v-text="$t('user.user-id-with-value', { id: user.id })" />
<h3 class="display-2 font-weight-light text--primary">
<small> {{ $t("group.group-with-value", { groupID: user.group }) }}</small>
</h3>
</div>
</template>
<template #actions>
<BaseDialog
:title="$t('user.reset-password')"
:title-icon="$globals.icons.lock"
:submit-text="$t('settings.change-password')"
:loading="loading"
:top="true"
@submit="changePassword"
>
<template #activator="{ open }">
<v-btn color="info" class="mr-1" small @click="open">
<v-icon left>{{ $globals.icons.lock }}</v-icon>
{{ $t("settings.change-password") }}
</v-btn>
</template>
<v-card-text>
<v-form ref="passChange">
<v-text-field
v-model="password.current"
:prepend-icon="$globals.icons.lock"
:label="$t('user.current-password')"
validate-on-blur
:type="showPassword ? 'text' : 'password'"
@click:append="showPassword.current = !showPassword.current"
></v-text-field>
<v-text-field
v-model="password.newOne"
:prepend-icon="$globals.icons.lock"
:label="$t('user.new-password')"
:type="showPassword ? 'text' : 'password'"
@click:append="showPassword.newOne = !showPassword.newOne"
></v-text-field>
<v-text-field
v-model="password.newTwo"
:prepend-icon="$globals.icons.lock"
:label="$t('user.confirm-password')"
:rules="[password.newOne === password.newTwo || $t('user.password-must-match')]"
validate-on-blur
:type="showPassword ? 'text' : 'password'"
@click:append="showPassword.newTwo = !showPassword.newTwo"
></v-text-field>
</v-form>
</v-card-text>
</BaseDialog>
</template>
<template #bottom>
<v-card-text>
<v-form ref="userUpdate">
<v-text-field v-model="user.username" :label="$t('user.username')" required validate-on-blur> </v-text-field>
<v-text-field v-model="user.fullName" :label="$t('user.full-name')" required validate-on-blur> </v-text-field>
<v-text-field v-model="user.email" :label="$t('user.email')" validate-on-blur required> </v-text-field>
</v-form>
</v-card-text>
<v-divider></v-divider>
<v-card-actions class="pb-1 pt-3">
<AppButtonUpload :icon="$globals.icons.fileImage" :text="$t('user.upload-photo')" file-name="profile_image" />
<v-spacer></v-spacer>
<BaseButton update @click="updateUser" />
</v-card-actions>
</template>
</BaseStatCard>
</template>
<script>
export default {
data() {
return {
hideImage: false,
passwordLoading: false,
password: {
current: "",
newOne: "",
newTwo: "",
},
showPassword: false,
loading: false,
user: {},
};
},
watch: {
userProfileImage() {
this.hideImage = false;
},
},
methods: {
async refreshProfile() {
const [response, err] = await api.users.self();
if (err) {
return; // TODO: Log or Notifty User of Error
}
this.user = response.data;
},
openAvatarPicker() {
this.showAvatarPicker = true;
},
selectAvatar(avatar) {
this.user.avatar = avatar;
},
async updateUser() {
if (!this.$refs.userUpdate.validate()) {
return;
}
this.loading = true;
const response = await api.users.update(this.user);
if (response) {
this.$store.commit("setToken", response.data.access_token);
this.refreshProfile();
this.loading = false;
this.$store.dispatch("requestUserData");
}
},
async changePassword() {
this.paswordLoading = true;
const data = {
currentPassword: this.password.current,
newPassword: this.password.newOne,
};
if (this.$refs.passChange.validate()) {
if (await api.users.changePassword(this.user.id, data)) {
this.$emit("refresh");
}
}
this.paswordLoading = false;
},
},
};
</script>
<style></style>

View file

@ -0,0 +1,211 @@
<template>
<div>
<BaseStatCard :icon="$globals.icons.formatColorFill" :color="color">
<template #after-heading>
<div class="ml-auto text-right">
<div class="body-3 grey--text font-weight-light" v-text="$t('general.themes')" />
<h3 class="display-2 font-weight-light text--primary">
<small> {{ selectedTheme.name }} </small>
</h3>
</div>
</template>
<template #actions>
<v-btn-toggle v-model="darkMode" color="primary " mandatory>
<v-btn small value="system">
<v-icon>{{ $globals.icons.desktopTowerMonitor }}</v-icon>
<span v-show="$vuetify.breakpoint.smAndUp" class="ml-1">
{{ $t("settings.theme.default-to-system") }}
</span>
</v-btn>
<v-btn small value="light">
<v-icon>{{ $globals.icons.weatherSunny }}</v-icon>
<span v-show="$vuetify.breakpoint.smAndUp" class="ml-1">
{{ $t("settings.theme.light") }}
</span>
</v-btn>
<v-btn small value="dark">
<v-icon>{{ $globals.icons.weatherNight }}</v-icon>
<span v-show="$vuetify.breakpoint.smAndUp" class="ml-1">
{{ $t("settings.theme.dark") }}
</span>
</v-btn>
</v-btn-toggle>
</template>
<template #bottom>
<v-virtual-scroll height="290" item-height="70" :items="availableThemes" class="mt-2">
<template #default="{ item }">
<v-divider></v-divider>
<v-list-item @click="selectedTheme = item">
<v-list-item-avatar>
<v-icon large dark :color="item.colors.primary">
{{ $globals.icons.formatColorFill }}
</v-icon>
</v-list-item-avatar>
<v-list-item-content>
<v-list-item-title v-text="item.name"></v-list-item-title>
<v-row flex align-center class="mt-2 justify-space-around px-4 pb-2">
<v-sheet
v-for="(clr, index) in item.colors"
:key="index"
class="rounded flex mx-1"
:color="clr"
height="20"
>
</v-sheet>
</v-row>
</v-list-item-content>
<v-list-item-action class="ml-auto">
<v-btn large icon @click.stop="editTheme(item)">
<v-icon color="accent">{{ $globals.icons.edit }}</v-icon>
</v-btn>
</v-list-item-action>
</v-list-item>
<v-divider></v-divider>
</template>
</v-virtual-scroll>
<v-divider></v-divider>
<v-card-actions>
<BaseButton class="ml-auto mt-1 mb-n1" create @click="createTheme" />
</v-card-actions>
</template>
</BaseStatCard>
<BaseDialog
ref="themeDialog"
:loading="loading"
:title="modalLabel.title"
:title-icon="$globals.icons.formatColorFill"
modal-width="700"
:submit-text="modalLabel.button"
@submit="processSubmit"
@delete="deleteTheme"
>
<v-card-text class="mt-3">
<v-text-field
v-model="defaultData.name"
:label="$t('settings.theme.theme-name')"
:append-outer-icon="jsonEditor ? $globals.icons.formSelect : $globals.icons.codeBraces"
@click:append-outer="jsonEditor = !jsonEditor"
></v-text-field>
<v-row v-if="defaultData.colors && !jsonEditor" dense dflex wrap justify-content-center>
<v-col v-for="(_, key) in defaultData.colors" :key="key" cols="12" sm="6">
<BaseColorPicker v-model="defaultData.colors[key]" :button-text="labels[key]" />
</v-col>
</v-row>
<!-- <VJsoneditor v-else v-model="defaultData" height="250px" :options="jsonEditorOptions" @error="logError()" /> -->
</v-card-text>
</BaseDialog>
</div>
</template>
<script>
export default {
components: {
// VJsoneditor: () => import(/* webpackChunkName: "json-editor" */ "v-jsoneditor"),
},
data() {
return {
jsonEditor: false,
jsonEditorOptions: {
mode: "code",
search: false,
mainMenuBar: false,
},
availableThemes: [],
color: "accent",
newTheme: false,
loading: false,
defaultData: {
name: "",
colors: {
primary: "#E58325",
accent: "#00457A",
secondary: "#973542",
success: "#43A047",
info: "#4990BA",
warning: "#FF4081",
error: "#EF5350",
},
},
};
},
computed: {
labels() {
return {
primary: this.$t("settings.theme.primary"),
secondary: this.$t("settings.theme.secondary"),
accent: this.$t("settings.theme.accent"),
success: this.$t("settings.theme.success"),
info: this.$t("settings.theme.info"),
warning: this.$t("settings.theme.warning"),
error: this.$t("settings.theme.error"),
};
},
modalLabel() {
if (this.newTheme) {
return {
title: this.$t("settings.add-a-new-theme"),
button: this.$t("general.create"),
};
} else {
return {
title: "Update Theme",
button: this.$t("general.update"),
};
}
},
selectedTheme: {
set(val) {
console.log(val);
},
get() {
return this.$vuetify.theme;
},
},
darkMode: {
set(val) {
console.log(val);
},
get() {
return false;
},
},
},
methods: {
async getAllThemes() {
this.availableThemes = await api.themes.requestAll();
},
editTheme(theme) {
this.defaultData = theme;
this.newTheme = false;
this.$refs.themeDialog.open();
},
createTheme() {
this.newTheme = true;
this.$refs.themeDialog.open();
},
async processSubmit() {
if (this.newTheme) {
await api.themes.create(this.defaultData);
} else {
await api.themes.update(this.defaultData);
}
this.getAllThemes();
},
async deleteTheme() {
await api.themes.delete(this.defaultData.id);
this.getAllThemes();
},
},
};
</script>
<style lang="scss" scoped>
</style>

View file

@ -250,7 +250,7 @@ export default defineComponent({
this.$router.push(`/recipe/${response.data.slug}`);
},
async manualCreateRecipe() {
await this.api.recipes.createOne(this.createRecipeData.form.name);
await this.api.recipes.createOne({ name: this.createRecipeData.form.name });
},
async createOnByUrl() {
this.error = false;

View file

@ -1,5 +1,5 @@
<template>
<v-navigation-drawer :value="value" clipped app width="200px">
<v-navigation-drawer :value="value" clipped app>
<!-- User Profile -->
<template v-if="$auth.user">
<v-list-item two-line to="/user/profile">
@ -14,11 +14,11 @@
</v-list-item>
<v-divider></v-divider>
</template>
<!-- Primary Links -->
<v-list nav dense>
<v-list-item-group v-model="topSelected" color="primary">
<v-list-item v-for="nav in topLink" :key="nav.title" link :to="nav.to">
<v-list-item v-for="nav in topLink" :key="nav.title" exact link :to="nav.to">
<v-list-item-icon>
<v-icon>{{ nav.icon }}</v-icon>
</v-list-item-icon>
@ -29,16 +29,40 @@
<!-- Secondary Links -->
<template v-if="secondaryLinks">
<v-subheader v-if="secondaryHeader" class="pb-0">{{ secondaryHeader }}</v-subheader>
<v-divider></v-divider>
<v-list nav dense>
<v-list-item-group v-model="secondarySelected" color="primary">
<v-list-item v-for="nav in secondaryLinks" :key="nav.title" link :to="nav.to">
<v-list-item-icon>
<v-icon>{{ nav.icon }}</v-icon>
</v-list-item-icon>
<v-list-item-title>{{ nav.title }}</v-list-item-title>
</v-list-item>
</v-list-item-group>
<template v-for="nav in secondaryLinks">
<!-- Multi Items -->
<v-list-group
v-if="nav.children"
:key="nav.title + 'multi-item'"
v-model="dropDowns[nav.title]"
color="primary"
:prepend-icon="nav.icon"
>
<template #activator>
<v-list-item-title>{{ nav.title }}</v-list-item-title>
</template>
<v-list-item v-for="child in nav.children" :key="child.title" :to="child.to">
<v-list-item-icon>
<v-icon>{{ child.icon }}</v-icon>
</v-list-item-icon>
<v-list-item-title>{{ child.title }}</v-list-item-title>
</v-list-item>
</v-list-group>
<!-- Single Item -->
<v-list-item-group v-else :key="nav.title + 'single-item'" v-model="secondarySelected" color="primary">
<v-list-item link :to="nav.to">
<v-list-item-icon>
<v-icon>{{ nav.icon }}</v-icon>
</v-list-item-icon>
<v-list-item-title>{{ nav.title }}</v-list-item-title>
</v-list-item>
</v-list-item-group>
</template>
</v-list>
</template>
@ -93,12 +117,17 @@ export default defineComponent({
required: false,
default: null,
},
secondaryHeader: {
type: String,
default: null,
},
},
setup() {
return {};
},
data() {
return {
dropDowns: {},
topSelected: null,
secondarySelected: null,
bottomSelected: null,

View file

@ -18,6 +18,7 @@
:label="inputField.label"
:name="inputField.varName"
:hint="inputField.hint || ''"
:disabled="updateMode && inputField.fixed"
@change="emitBlur"
/>

View file

@ -1,6 +1,7 @@
<template>
<v-card flat class="pb-2">
<h2>{{ title }}</h2>
<h2 class="headline">{{ title }}</h2>
<BaseDivider width="200px" color="primary" class="my-2" thickness="1px" />
<p class="pb-0 mb-0">
<slot />
</p>
@ -12,8 +13,8 @@ export default {
props: {
title: {
type: String,
default: "Place Holder"
}
}
}
default: "Place Holder",
},
},
};
</script>

View file

@ -0,0 +1,64 @@
<template>
<div>
<div class="text-center">
<h3>{{ buttonText }}</h3>
</div>
<v-text-field v-model="color" hide-details class="ma-0 pa-0" solo>
<template #append>
<v-menu v-model="menu" top nudge-bottom="105" nudge-left="16" :close-on-content-click="false">
<template #activator="{ on }">
<div :style="swatchStyle" swatches-max-height="300" v-on="on" />
</template>
<v-card>
<v-card-text class="pa-0">
<v-color-picker v-model="color" flat mode="hexa" show-swatches />
</v-card-text>
</v-card>
</v-menu>
</template>
</v-text-field>
</div>
</template>
<script>
export default {
props: {
buttonText: String,
value: String,
},
data() {
return {
dialog: false,
swatches: false,
color: this.value || "#1976D2",
mask: "!#XXXXXXXX",
menu: false,
};
},
computed: {
swatchStyle() {
const { value, menu } = this;
return {
backgroundColor: value,
cursor: "pointer",
height: "30px",
width: "30px",
borderRadius: menu ? "50%" : "4px",
transition: "border-radius 200ms ease-in-out",
};
},
},
watch: {
color() {
this.updateColor();
},
},
methods: {
updateColor() {
this.$emit("input", this.color);
},
},
};
</script>
<style></style>

View file

@ -33,9 +33,12 @@
<BaseButton v-if="$listeners.delete" delete secondary @click="deleteEvent" />
<BaseButton v-if="$listeners.confirm" :color="color" type="submit" @click="$emit('confirm')">
<template #icon>
{{ $globals.icons.check }}
</template>
{{ $t("general.confirm") }}
</BaseButton>
<BaseButton v-else-if="$listeners.submit" type="submit" @click="submitEvent">
<BaseButton v-if="$listeners.submit" type="submit" @click="submitEvent">
{{ submitText }}
</BaseButton>
</slot>
@ -108,6 +111,7 @@ export default defineComponent({
},
dialog(val) {
if (val) this.submitted = false;
if (!val) this.$emit("close");
},
},
methods: {
@ -130,4 +134,9 @@ export default defineComponent({
});
</script>
<style></style>
<style>
.top-dialog {
position: fixed;
top: 0;
}
</style>

View file

@ -1,5 +1,5 @@
<template>
<v-divider :width="width" class="mx-auto" :class="color" :style="`border-width: ${thickness} !important`" />
<v-divider :width="width" :class="color" :style="`border-width: ${thickness} !important`" />
</template>
<script>
@ -7,16 +7,16 @@ export default {
props: {
width: {
type: String,
default: "100px"
default: "100px",
},
thickness: {
type: String,
default: "2px"
default: "2px",
},
color: {
type: String,
default: "accent"
}
}
}
default: "accent",
},
},
};
</script>

View file

@ -0,0 +1,103 @@
w<template>
<v-card v-bind="$attrs" :class="classes" class="v-card--material pa-3">
<div class="d-flex grow flex-wrap">
<slot name="avatar">
<v-sheet
:color="color"
:max-height="icon ? 90 : undefined"
:width="icon ? 'auto' : '100%'"
elevation="6"
class="text-start v-card--material__heading mb-n6 mt-n10 pa-7"
dark
>
<v-icon v-if="icon" size="40" v-text="icon" />
<div v-if="text" class="headline font-weight-thin" v-text="text" />
</v-sheet>
</slot>
<div v-if="$slots['after-heading']" class="ml-auto">
<slot name="after-heading" />
</div>
</div>
<slot />
<template v-if="$slots.actions">
<v-divider class="mt-2" />
<v-card-actions class="pb-0">
<slot name="actions" />
</v-card-actions>
</template>
<template v-if="$slots.bottom">
<v-divider v-if="!$slots.actions" class="mt-2" />
<div class="pb-0">
<slot name="bottom" />
</div>
</template>
</v-card>
</template>
<script>
export default {
name: "MaterialCard",
props: {
avatar: {
type: String,
default: "",
},
color: {
type: String,
default: "primary",
},
icon: {
type: String,
default: undefined,
},
image: {
type: Boolean,
default: false,
},
text: {
type: String,
default: "",
},
title: {
type: String,
default: "",
},
},
computed: {
classes() {
return {
"v-card--material--has-heading": this.hasHeading,
"mt-3": this.$vuetify.breakpoint.name === "xs" || this.$vuetify.breakpoint.name === "sm",
};
},
hasHeading() {
return false;
},
hasAltHeading() {
return false;
},
},
};
</script>
<style lang="sass">
.v-card--material
&__avatar
position: relative
top: -64px
margin-bottom: -32px
&__heading
position: relative
top: -40px
transition: .3s ease
z-index: 1
</style>