Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add plus for ref inputs #2922

Merged
merged 5 commits into from
Nov 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,12 @@ import ButtonAction from "./ButtonAction.vue";
import RowEdit from "./RowEdit.vue";
import RowEditFooter from "./RowEditFooter.vue";
import Tooltip from "./Tooltip.vue";
import { isColumnVisible } from "./formUtils/formUtils";
import {
filterVisibleColumns,
getChapterStyle,
getRowErrors,
getSaveDisabledMessage,
isColumnVisible,
removeKeyColumns,
splitColumnNamesByHeadings,
} from "./formUtils/formUtils";
Expand Down
7 changes: 2 additions & 5 deletions apps/molgenis-components/src/components/forms/InputRef.vue
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,8 @@ export default {
type: String,
required: true,
},
/**
* Whether or not the buttons are show to edit the referenced table
* */
canEdit: {
type: Boolean,
required: false,
default: () => false,
},
},
Expand Down Expand Up @@ -173,7 +169,8 @@ export default {
<docs>
<template>
<div>
You have to be have server running and be signed in for this to work
You have to be have server running and be signed in for this to work.
Note: this component is currently only used in the RefFilter. For inputting Ref entries in forms, InputRefList is used.
<div class="border-bottom mb-3 p-2">
<h5>synced demo props: </h5>
<div>
Expand Down
74 changes: 43 additions & 31 deletions apps/molgenis-components/src/components/forms/InputRefList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@
/>
</div>
<ButtonAlt
v-if="modelValue && modelValue.length"
v-if="modelValue?.length"
class="pl-1"
icon="fa fa-clear"
@click="clearValue"
>
clear selection
Expand Down Expand Up @@ -51,14 +52,27 @@
{{ applyJsTemplate(row, refLabel) }}
</label>
</div>
<ButtonAlt
class="pl-0"
:class="showMultipleColumns ? 'col-12 col-md-6 col-lg-4' : ''"
icon="fa fa-search"
@click="openSelect"
>
{{ count > maxNum ? `view all ${count} options.` : "view as table" }}
</ButtonAlt>
<div v-if="canEdit">
<Tooltip value="New entry">
<RowButtonAdd
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should hid '+' if the refTable is NOT current schema (or find a way to quickly find out if we have permission on that other schema).

id="add-entry"
:tableName="tableName"
:schemaName="schemaName"
/>
</Tooltip>
</div>
<div>
<ButtonAlt
class="pl-0"
:class="showMultipleColumns ? 'col-12 col-md-6 col-lg-4' : ''"
icon="fa fa-search"
@click="openSelect"
>
{{
count > maxNum ? `view all ${count} options.` : "view as table"
}}
</ButtonAlt>
</div>
</div>
<LayoutModal v-if="showSelect" :title="title" @close="closeSelect">
<template v-slot:body>
Expand All @@ -83,20 +97,24 @@
</FormGroup>
</template>

<script>
import Client from "../../client/client.ts";
<script lang="ts">
import { IRow } from "../../Interfaces/IRow";
import { IQueryMetaData } from "../../client/IQueryMetaData";
import Client from "../../client/client";
import FilterWell from "../filters/FilterWell.vue";
import LayoutModal from "../layout/LayoutModal.vue";
import Spinner from "../layout/Spinner.vue";
import BaseInput from "./baseInputs/BaseInput.vue";
import RowButtonAdd from "../tables/RowButtonAdd.vue";
import TableSearch from "../tables/TableSearch.vue";
import LayoutModal from "../layout/LayoutModal.vue";
import FormGroup from "./FormGroup.vue";
import ButtonAlt from "./ButtonAlt.vue";
import FilterWell from "../filters/FilterWell.vue";
import {
convertToPascalCase,
convertRowToPrimaryKey,
applyJsTemplate,
convertRowToPrimaryKey,
convertToPascalCase,
} from "../utils";
import ButtonAlt from "./ButtonAlt.vue";
import FormGroup from "./FormGroup.vue";
import Tooltip from "./Tooltip.vue";
import BaseInput from "./baseInputs/BaseInput.vue";

export default {
extends: BaseInput,
Expand All @@ -118,6 +136,8 @@ export default {
FormGroup,
ButtonAlt,
Spinner,
RowButtonAdd,
Tooltip,
},
props: {
schemaName: {
Expand All @@ -136,12 +156,8 @@ export default {
type: String,
required: true,
},
/**
* Whether or not the buttons are show to edit the referenced table
* */
canEdit: {
type: Boolean,
required: false,
default: () => false,
},
},
Expand All @@ -159,7 +175,7 @@ export default {
},
methods: {
applyJsTemplate,
deselect(key) {
deselect(key: any) {
this.selection.splice(key, 1);
this.emitSelection();
},
Expand All @@ -179,21 +195,17 @@ export default {
},
async loadOptions() {
this.loading = true;
const options = {
const options: IQueryMetaData = {
limit: this.maxNum,
filter: this.filter,
orderby: this.orderby,
};
if (this.filter) {
options["filter"] = this.filter;
}
if (this.orderby) {
options["orderby"] = this.orderby;
}
const response = await this.client.fetchTableData(this.tableId, options);
this.data = response[this.tableId];
this.count = response[this.tableId + "_agg"].count;

await Promise.all(
this.data.map(async (row) => {
this.data.map(async (row: IRow) => {
row.primaryKey = await convertRowToPrimaryKey(
row,
this.tableId,
Expand Down