Skip to content

Commit

Permalink
Allow per field conditions, adjust displaying of purged users
Browse files Browse the repository at this point in the history
  • Loading branch information
guerler committed Nov 28, 2023
1 parent b4d9eac commit aafc0d5
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 28 deletions.
57 changes: 30 additions & 27 deletions client/src/components/Grid/GridList.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script setup lang="ts">
import { library } from "@fortawesome/fontawesome-svg-core";
import { faCaretDown, faCaretUp } from "@fortawesome/free-solid-svg-icons";
import { faCaretDown, faCaretUp, faShieldAlt } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/vue-fontawesome";
import { useDebounceFn, useEventBus } from "@vueuse/core";
import { BAlert, BButton, BLink, BPagination } from "bootstrap-vue";
Expand All @@ -22,7 +22,7 @@ import UtcDate from "@/components/UtcDate.vue";
const eventBus = useEventBus<string>("grid-router-push");
const router = useRouter();
library.add(faCaretDown, faCaretUp);
library.add(faCaretDown, faCaretUp, faShieldAlt);
interface Props {
// provide a grid configuration
Expand Down Expand Up @@ -251,31 +251,34 @@ watch(operationMessage, () => {
class="px-2 py-3"
:style="{ width: `${fieldEntry.width}%` }"
:data-description="`grid cell ${rowIndex}-${fieldIndex}`">
<GridOperations
v-if="fieldEntry.type == 'operations' && fieldEntry.operations"
:operations="fieldEntry.operations"
:row-data="rowData"
:title="rowData[fieldEntry.key]"
@execute="onOperation($event, rowData)" />
<GridBoolean v-else-if="fieldEntry.type == 'boolean'" :value="rowData[fieldEntry.key]" />
<GridText v-else-if="fieldEntry.type == 'text'" :text="rowData[fieldEntry.key]" />
<GridLink
v-else-if="fieldEntry.type == 'link'"
:text="rowData[fieldEntry.key]"
@click="fieldEntry.handler && fieldEntry.handler(rowData)" />
<SharingIndicators
v-else-if="fieldEntry.type == 'sharing'"
:object="rowData"
@filter="onFilter($event)" />
<UtcDate v-else-if="fieldEntry.type == 'date'" :date="rowData[fieldEntry.key]" mode="elapsed" />
<StatelessTags
v-else-if="fieldEntry.type == 'tags'"
clickable
:value="rowData[fieldEntry.key]"
:disabled="fieldEntry.disabled"
@input="onTagInput(rowData, $event, fieldEntry.handler)"
@tag-click="applyFilter('tag', $event, true)" />
<span v-else v-localize> Data not available. </span>
<div v-if="!fieldEntry.condition || fieldEntry.condition(rowData)">
<GridOperations
v-if="fieldEntry.type == 'operations' && fieldEntry.operations"
:operations="fieldEntry.operations"
:row-data="rowData"
:title="rowData[fieldEntry.key]"
@execute="onOperation($event, rowData)" />
<GridBoolean v-else-if="fieldEntry.type == 'boolean'" :value="rowData[fieldEntry.key]" />
<GridText v-else-if="fieldEntry.type == 'text'" :text="rowData[fieldEntry.key]" />
<GridLink
v-else-if="fieldEntry.type == 'link'"
:text="rowData[fieldEntry.key]"
@click="fieldEntry.handler && fieldEntry.handler(rowData)" />
<SharingIndicators
v-else-if="fieldEntry.type == 'sharing'"
:object="rowData"
@filter="onFilter($event)" />
<UtcDate v-else-if="fieldEntry.type == 'date'" :date="rowData[fieldEntry.key]" mode="elapsed" />
<StatelessTags
v-else-if="fieldEntry.type == 'tags'"
clickable
:value="rowData[fieldEntry.key]"
:disabled="fieldEntry.disabled"
@input="onTagInput(rowData, $event, fieldEntry.handler)"
@tag-click="applyFilter('tag', $event, true)" />
<span v-else v-localize> Not available. </span>
</div>
<FontAwesomeIcon v-else icon="fa-shield-alt" />
</td>
</tr>
</table>
Expand Down
3 changes: 2 additions & 1 deletion client/src/components/Grid/configs/adminUsers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ const fields = [
key: "email",
title: "Email",
type: "operations",
condition: (data: UserEntry) => !data.deleted,
condition: (data: UserEntry) => !data.deleted && !data.purged,
operations: [
{
title: "Manage Information",
Expand Down Expand Up @@ -257,6 +257,7 @@ const fields = [
key: "username",
title: "Username",
type: "text",
condition: (data: UserEntry) => !data.purged,
},
{
key: "last_login",
Expand Down

0 comments on commit aafc0d5

Please sign in to comment.