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

FOUR-13921 create a sortable component table #1543

Merged
merged 29 commits into from
Feb 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
f9f6e22
feat: add sortable filter ui
Feb 19, 2024
a5ab811
feat: add sortable list ui
Feb 19, 2024
3afbd4a
feat: add d&d event to sortable component
Feb 19, 2024
ee1603a
feat: sort by order attr
Feb 20, 2024
872ccdf
Merge branch 'feature/FOUR-13446' into feature/FOUR-13921
Feb 20, 2024
b10b674
Add selectors for testing
caleeli Feb 20, 2024
6e70cb6
Create storybook for Sortable component
caleeli Feb 20, 2024
730e9ac
Change CBs to events
caleeli Feb 21, 2024
9a09d39
feat: improve drag and drop
Feb 21, 2024
1ba61af
feat: filter pages
Feb 21, 2024
562ca91
feat: add scroll to pages list
Feb 21, 2024
5c29b59
Merge branch 'feature/FOUR-13446' into feature/FOUR-13921
Feb 21, 2024
5006324
feat: open pages from dropdown
Feb 21, 2024
e53dc6d
add b-form-input for edirt mode
Feb 21, 2024
2fa5d14
disable edit mode on drag start
Feb 21, 2024
da66433
Implement delete page
caleeli Feb 21, 2024
dc7e12b
add textbox blur ever
Feb 21, 2024
ac4853d
fix to open all pages modal
Feb 21, 2024
67b4800
remove unused data
Feb 21, 2024
d41cbe7
enable plus opening add page modal
Feb 21, 2024
e0fb842
Merge remote-tracking branch 'origin/feature/FOUR-13921' into feature…
Feb 21, 2024
e898841
Add new toolbar
caleeli Feb 21, 2024
896c231
add autofocus
Feb 21, 2024
95cd643
feat: add order attr on create page
Feb 21, 2024
d710f9e
update screen toolbar
Feb 21, 2024
aac7504
Merge remote-tracking branch 'origin/feature/FOUR-13921' into feature…
Feb 21, 2024
4d18623
add undo/redo
Feb 21, 2024
2f98cfd
Change button to confirm
caleeli Feb 21, 2024
a0610d3
Add missing property to test
caleeli Feb 21, 2024
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
84 changes: 30 additions & 54 deletions src/App.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<template>
<b-container id="screen-builder-container" class="h-100">
<b-card id="app" no-body class="h-100 bg-white border-top-0">
<b-card id="app" no-body class="h-100 bg-white border-top-0 ">
<!-- Card Header -->
<b-card-header>
<b-card-header class="bg-white">
<b-row>
<b-col>
<b-button-group size="sm pr-2">
Expand Down Expand Up @@ -49,60 +49,33 @@
</b-col>

<b-col v-if="displayBuilder && !displayPreview" class="text-right">
<div
class="btn-group btn-group-sm mr-2"
role="group"
aria-label="Basic example"
<screen-toolbar
@undo="$refs.builder.undo()"
@redo="$refs.builder.redo()"
@open-calc="openComputedProperties"
@open-customCss="openCustomCSS"
@open-watchers="openWatchersPopup"
>
<button
type="button"
class="btn btn-secondary"
:title="$t('Calculated Properties')"
data-cy="topbar-calcs"
@click="openComputedProperties"
<b-btn
v-b-modal="'uploadmodal'"
variant="secondary"
size="sm"
class="mr-2"
:title="$t('Load Screen')"
>
<i class="fas fa-flask" />
{{ $t("Calcs") }}
</button>
<button
type="button"
class="btn btn-secondary"
:title="$t('Custom CSS')"
data-cy="topbar-css"
@click="openCustomCSS"
<i class="fas fa-upload mr-1" />
</b-btn>
<b-btn
v-b-modal.preview-config
variant="secondary"
size="sm"
class="mr-2"
:title="$t('Save Screen')"
@click="saveToLocalStorage()"
>
<i class="fab fa-css3" />
{{ $t("CSS") }}
</button>
<button
type="button"
class="btn btn-secondary"
:title="$t('Watchers')"
data-cy="topbar-watchers"
@click="openWatchersPopup"
>
<i class="fas fa-mask" />
{{ $t("Watchers") }}
</button>
</div>
<b-btn
v-b-modal="'uploadmodal'"
variant="secondary"
size="sm"
class="mr-2"
:title="$t('Load Screen')"
>
<i class="fas fa-upload mr-1" />
</b-btn>
<button
v-b-modal.preview-config
type="button"
class="btn btn-secondary btn-sm ml-1"
:title="$t('Save Screen')"
@click="saveToLocalStorage()"
>
<i class="fas fa-save" />
</button>
<i class="fas fa-save mr-1" />
</b-btn>
</screen-toolbar>
</b-col>
<b-modal
id="uploadmodal"
Expand Down Expand Up @@ -351,6 +324,7 @@ import WatchersPopup from "./components/watchers-popup.vue";
import CustomCss from "./components/custom-css.vue";
import VueFormBuilder from "./components/vue-form-builder.vue";
import VueFormRenderer from "./components/vue-form-renderer.vue";
import ScreenToolbar from "./components/ScreenToolbar.vue";
import canOpenJsonFile from "./mixins/canOpenJsonFile";

// Bring in our initial set of controls
Expand Down Expand Up @@ -411,7 +385,8 @@ export default {
VueFormBuilder,
VueFormRenderer,
MonacoEditor,
WatchersPopup
WatchersPopup,
ScreenToolbar,
},
mixins: [canOpenJsonFile],
data() {
Expand Down Expand Up @@ -787,6 +762,7 @@ body {

.card-header {
border-radius: 0 !important;
background-color: none !important;
}

.border-check {
Expand Down
100 changes: 100 additions & 0 deletions src/components/ScreenToolbar.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
<template>
<div class="flex-grow-1 d-flex flex-row-reverse">
<b-button-group size="sm" class="bg-white p-2 screen-toolbar">
<b-button
class="screen-toolbar-button"
variant="link"
:disabled="!canUndo"
data-cy="toolbar-undo"
@click="$emit('undo')"
>
<i class="fas fa-undo" />
{{ $t("Undo") }}
</b-button>
<b-button
class="screen-toolbar-button"
variant="link"
:disabled="!canRedo"
data-cy="toolbar-redo"
@click="$emit('redo')"
>
<i class="fas fa-redo" />
{{ $t("Redo") }}
</b-button>
<b-button
type="button"
class="screen-toolbar-button"
variant="link"
:title="$t('Calculated Properties')"
data-cy="topbar-calcs"
@click="$emit('open-calc')"
>
<i class="fas fa-flask" />
{{ $t("Calcs") }}
</b-button>
<b-button
type="button"
class="screen-toolbar-button"
variant="link"
:title="$t('Custom CSS')"
data-cy="topbar-css"
@click="$emit('open-customCss')"
>
<i class="fab fa-css3" />
{{ $t("CSS") }}
</b-button>
<b-button
type="button"
class="screen-toolbar-button"
variant="link"
:title="$t('Watchers')"
data-cy="topbar-watchers"
@click="$emit('open-watchers')"
>
<i class="fas fa-mask" />
{{ $t("Watchers") }}
</b-button>
<b-dropdown
type="button"
class="screen-toolbar-button"
variant="outlined-secondary"
:popper-opts="{ placement: 'bottom-end' }"
data-cy="topbar-options"
>
<template v-slot:button-content>
<span class="screen-toolbar-button">
<i class="fas fa-cog" />
{{ $t("Options") }}
</span>
</template>
<template v-slot:default>
<slot />
</template>
</b-dropdown>
</b-button-group>
</div>
</template>

<script>
export default {
data() {
return {
showToolbar: true
};
},
computed: {
canUndo() {
return this.$store.getters["undoRedoModule/canUndo"];
},
canRedo() {
return this.$store.getters["undoRedoModule/canRedo"];
},
}
};
</script>

<style scoped>
.screen-toolbar-button {
color: #556271;
}
</style>
63 changes: 63 additions & 0 deletions src/components/sortable/Sortable.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<template>
<div class="container sortable-box">
<div class="row">
<div class="col-sm border rounded-lg p-0 mr-3 sortable-search-box">
<i class="fa fa-search sortable-search-icon"></i>
<input
id="search"
class="form-control border-0 shadow-none px-0"
v-model="search"
:placeholder="$t('Search here')"
data-test="search"
/>
</div>
<div>
<button
type="button"
class="btn sortable-btn-new"
@click="$emit('add-page', $event)"
>
<i class="fa fa-plus"></i>
</button>
</div>
</div>

<SortableList
:items="items"
:filtered-items="filteredItems"
@ordered="$emit('ordered', $event)"
@item-edit="$emit('item-edit', $event)"
@item-delete="$emit('item-delete', $event)"
/>
</div>
</template>

<script>
import SortableList from './sortableList/SortableList.vue'

export default {
name: 'Sortable',
components: {
SortableList
},
props: {
items: { type: Array, required: true },
filterKey: { type: String, required: true },
},
data() {
return {
search: "",
filteredItems: this.items,
};
},
watch: {
search(value) {
const cleanValue = value.trim().toLowerCase();

this.filteredItems = this.items.filter((item) => item[this.filterKey].toLowerCase().includes(cleanValue));
},
}
}
</script>

<style lang="scss" scoped src="./sortable.scss"></style>
25 changes: 25 additions & 0 deletions src/components/sortable/sortable.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
.sortable {
&-box {
font-family: "Open Sans", sans-serif !important;
}

&-search-box {
display: flex;
align-items: center;
border-color: #cdddee !important;
}

&-search-icon {
margin: {
left: 16px;
right: 8px;
}
color: #6A7888;
}

&-btn-new {
background: #1572C2;
color: #ffffff;
}
}

Loading
Loading