-
Notifications
You must be signed in to change notification settings - Fork 100
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
Add basic jspreadsheet POC [SCI-11099] #7944
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,8 @@ import 'bootstrap'; | |
require('bootstrap-select/js/bootstrap-select'); | ||
import '@vuepic/vue-datepicker/dist/main.css'; | ||
import 'vue3-draggable-resizable/dist/Vue3DraggableResizable.css' | ||
import "jsuites/dist/jsuites.css"; | ||
import "jspreadsheet/dist/jspreadsheet.css"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Import in body of module; reorder to top import/first |
||
|
||
window.bwipjs = require('bwip-js'); | ||
window.Decimal = require('decimal.js'); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,11 @@ | ||
@import "bootstrap-select/sass/bootstrap-select"; | ||
@import "ag-grid-community/styles/ag-grid.css"; | ||
@import "ag-grid-community/styles/ag-theme-alpine.css"; | ||
|
||
|
||
/// Must be relplaced with our icons | ||
@import '~material-icons-font/sass/variables'; // mandatory and at first place | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Prefer double-quoted strings |
||
@import '~material-icons-font/sass/mixins'; // mandatory and after variables | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Prefer double-quoted strings |
||
$MaterialIcons_FontPath: "~material-icons-font/fonts"; // for CLI project we change font path to point into package fonts folder | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Name of variable |
||
@import '~material-icons-font/sass/main'; // mandatory main material font definition | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Prefer double-quoted strings |
||
@import '~material-icons-font/sass/Regular'; // mandatory @font-face definition | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Prefer double-quoted strings |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,6 +32,22 @@ | |
@delete="showDeleteModal" | ||
></MenuDropdown> | ||
</div> | ||
<Spreadsheet | ||
ref="spreadsheet" | ||
:license="license" | ||
:tabs="true" | ||
:toolbar="true" | ||
:allowExport="true" | ||
:onchange="update" | ||
:oninsertrow="update" | ||
:oninsertcolumn="update" | ||
:ondeletecolumn="update" | ||
:ondeleterow="update" | ||
:onmoverow="update" | ||
:onmovecolumn="update" | ||
> | ||
<Worksheet :data="tableData" :tableOverflow="true" tableWidth="600" resize="both" /> | ||
</Spreadsheet> | ||
<div class="table-body group/table-body relative border-solid border-transparent" | ||
:class="{'edit border-sn-light-grey': editingTable, 'view': !editingTable, 'locked': !element.attributes.orderable.urls.update_url}" | ||
tabindex="0" | ||
|
@@ -63,11 +79,18 @@ import InlineEdit from '../inline_edit.vue'; | |
import TableNameModal from './modal/table_name.vue'; | ||
import moveElementModal from './modal/move.vue'; | ||
import MenuDropdown from '../menu_dropdown.vue'; | ||
import { Spreadsheet, Worksheet } from "@jspreadsheet/vue"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Strings must use singlequote quotes |
||
|
||
export default { | ||
name: 'ContentTable', | ||
components: { | ||
deleteElementModal, InlineEdit, TableNameModal, moveElementModal, MenuDropdown | ||
deleteElementModal, | ||
InlineEdit, | ||
TableNameModal, | ||
moveElementModal, | ||
MenuDropdown, | ||
Spreadsheet, | ||
Worksheet | ||
}, | ||
mixins: [DeleteMixin, DuplicateMixin, MoveMixin], | ||
props: { | ||
|
@@ -96,13 +119,14 @@ export default { | |
}, | ||
data() { | ||
return { | ||
tableData: [], | ||
editingName: false, | ||
editingTable: false, | ||
editingCell: false, | ||
tableObject: null, | ||
nameModalOpen: false, | ||
reloadHeader: 0, | ||
updatingTableData: false | ||
updatingTableData: false, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unexpected trailing comma comma-dangle |
||
}; | ||
}, | ||
computed: { | ||
|
@@ -143,6 +167,8 @@ export default { | |
} | ||
}, | ||
created() { | ||
this.license = document.querySelector('meta[name="jspreadsheet-key"]').getAttribute('content'); | ||
this.tableData = JSON.parse(this.element.attributes.orderable.contents).data; | ||
window.addEventListener('beforeunload', this.showSaveWarning); | ||
}, | ||
beforeUnmount() { | ||
|
@@ -152,7 +178,7 @@ export default { | |
if (!this.updatingTableData) this.loadTableData(); | ||
}, | ||
beforeUpdate() { | ||
if (!this.updatingTableData) this.tableObject.destroy(); | ||
//if (!this.updatingTableData) this.tableObject.destroy(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Expected space or tab after '//' in comment spaced-comment |
||
}, | ||
mounted() { | ||
this.loadTableData(); | ||
|
@@ -227,6 +253,14 @@ export default { | |
}); | ||
}, | ||
update(callback = () => {}) { | ||
if (this.$refs.spreadsheet?.current) { | ||
const newTableData = this.$refs.spreadsheet.current[0].getData(); | ||
|
||
this.element.attributes.orderable.contents = JSON.stringify({ data: newTableData }); | ||
this.$emit('update', this.element, false, callback); | ||
} | ||
|
||
/* | ||
this.element.attributes.orderable.contents = JSON.stringify({ data: this.tableObject.getData() }); | ||
const metadata = this.element.attributes.orderable.metadata || {}; | ||
if (metadata.plateTemplate) { | ||
|
@@ -265,7 +299,8 @@ export default { | |
}); | ||
} | ||
|
||
this.$emit('update', this.element, false, callback); | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. More than 1 blank line not allowed no-multiple-empty-lines |
||
*/ | ||
}, | ||
updateTableData() { | ||
if (this.editingTable === false) return; | ||
|
@@ -278,6 +313,7 @@ export default { | |
}); | ||
}, | ||
loadTableData() { | ||
return | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing semicolon semi |
||
const container = this.$refs.hotTable; | ||
const data = JSON.parse(this.element.attributes.orderable.contents); | ||
const metadata = this.element.attributes.orderable.metadata || {}; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Import in body of module; reorder to top import/first
Strings must use singlequote quotes