diff --git a/Jenkinsfile b/Jenkinsfile index 341fffefa..ea3f1b439 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -12,18 +12,18 @@ def BRANCH_ENV = [ node { stage('Setup') { env.NODE_ENV = BRANCH_ENV[env.BRANCH_NAME] ?: 'dev' - PROTECTED_BRANCH = [ 'dev', 'test', 'master', 'main', 'beta' - ].contains(env.BRANCH_NAME) + ] + IS_PROTECTED_BRANCH = PROTECTED_BRANCH.contains(env.BRANCH_NAME) IS_LATEST = ['master', 'main'].contains(env.BRANCH_NAME) - // https://www.jenkins.io/doc/book/pipeline/jenkinsfile/#using-environment-variables + // https://www.jenkins.io/doc/book/pipeline/jenkinsfile/#using-environment-variables echo "NODE_NAME: ${env.NODE_NAME}" echo "WORKSPACE: ${env.WORKSPACE}" @@ -36,7 +36,7 @@ node { props.each {key, value -> echo "${key}: ${value}" } } - if (PROTECTED_BRANCH) { + if (IS_PROTECTED_BRANCH) { configFileProvider([ configFile(fileId: "salix-front.branch.${env.BRANCH_NAME}", variable: 'BRANCH_PROPS_FILE') @@ -63,7 +63,7 @@ pipeline { stages { stage('Version') { when { - expression { PROTECTED_BRANCH } + expression { IS_PROTECTED_BRANCH } } steps { script { @@ -84,7 +84,7 @@ pipeline { } stage('Test') { when { - expression { !PROTECTED_BRANCH } + expression { !IS_PROTECTED_BRANCH } } environment { NODE_ENV = '' @@ -94,7 +94,7 @@ pipeline { parallel { stage('Unit') { steps { - sh 'pnpm run test:unit:ci' + sh 'pnpm run test:front:ci' } post { always { @@ -113,10 +113,12 @@ pipeline { } steps { script { + sh 'rm junit/e2e-*.xml || true' + env.COMPOSE_TAG = PROTECTED_BRANCH.contains(env.CHANGE_TARGET) ? env.CHANGE_TARGET : 'dev' def image = docker.build('lilium-dev', '-f docs/Dockerfile.dev docs') sh "docker-compose ${env.COMPOSE_PARAMS} up -d" image.inside("--network ${env.COMPOSE_PROJECT}_default -e CI -e TZ") { - sh 'cypress run --browser chromium' + sh 'cypress run --browser chromium || true' } } } @@ -124,7 +126,7 @@ pipeline { always { sh "docker-compose ${env.COMPOSE_PARAMS} down -v" junit( - testResults: 'junit/e2e.xml', + testResults: 'junit/e2e-*.xml', allowEmptyResults: true ) } @@ -134,10 +136,9 @@ pipeline { } stage('Build') { when { - expression { PROTECTED_BRANCH } + expression { IS_PROTECTED_BRANCH } } environment { - CREDENTIALS = credentials('docker-registry') VERSION = readFile 'VERSION.txt' } steps { @@ -156,7 +157,7 @@ pipeline { } stage('Deploy') { when { - expression { PROTECTED_BRANCH } + expression { IS_PROTECTED_BRANCH } } environment { VERSION = readFile 'VERSION.txt' diff --git a/README.md b/README.md index e87a84d60..262e12e58 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ quasar dev ### Run unit tests ```bash -pnpm run test:unit +pnpm run test:front ``` ### Run e2e tests diff --git a/cypress.config.js b/cypress.config.js index dfe963a12..5cf075e2a 100644 --- a/cypress.config.js +++ b/cypress.config.js @@ -6,7 +6,7 @@ if (process.env.CI) { urlHost = 'front'; reporter = 'junit'; reporterOptions = { - mochaFile: 'junit/e2e.xml', + mochaFile: 'junit/e2e-[hash].xml', toConsole: false, }; } else { diff --git a/package.json b/package.json index e78b0cf3c..1361d1fd8 100644 --- a/package.json +++ b/package.json @@ -14,8 +14,8 @@ "test:e2e": "cypress open", "test:e2e:ci": "npm run resetDatabase && cd ../salix-front && cypress run", "test": "echo \"See package.json => scripts for available tests.\" && exit 0", - "test:unit": "vitest", - "test:unit:ci": "vitest run", + "test:front": "vitest", + "test:front:ci": "vitest run", "commitlint": "commitlint --edit", "prepare": "npx husky install", "addReferenceTag": "node .husky/addReferenceTag.js", diff --git a/src/components/FormModel.vue b/src/components/FormModel.vue index 182eeaafe..c4d9a4149 100644 --- a/src/components/FormModel.vue +++ b/src/components/FormModel.vue @@ -96,6 +96,10 @@ const $props = defineProps({ type: [String, Boolean], default: '800px', }, + onDataSaved: { + type: Function, + default: () => {}, + }, }); const emit = defineEmits(['onFetch', 'onDataSaved']); const modelValue = computed( diff --git a/src/components/VnTable/VnTable.vue b/src/components/VnTable/VnTable.vue index c1e541abb..7e9f7aae0 100644 --- a/src/components/VnTable/VnTable.vue +++ b/src/components/VnTable/VnTable.vue @@ -134,6 +134,10 @@ const $props = defineProps({ createComplement: { type: Object, }, + dataCy: { + type: String, + default: 'vn-table', + }, }); const { t } = useI18n(); @@ -249,7 +253,9 @@ function splitColumns(columns) { col.columnFilter = { inWhere: true, ...col.columnFilter }; splittedColumns.value.columns.push(col); } - // Status column + + splittedColumns.value.create = createOrderSort(splittedColumns.value.create); + if (splittedColumns.value.chips.length) { splittedColumns.value.columnChips = splittedColumns.value.chips.filter( (c) => !c.isId, @@ -265,6 +271,24 @@ function splitColumns(columns) { } } +function createOrderSort(columns) { + const orderedColumn = columns + .map((column, index) => + column.createOrder !== undefined ? { ...column, originalIndex: index } : null, + ) + .filter((item) => item !== null); + + orderedColumn.sort((a, b) => a.createOrder - b.createOrder); + + const filteredColumns = columns.filter((col) => col.createOrder === undefined); + + orderedColumn.forEach((col) => { + filteredColumns.splice(col.createOrder, 0, col); + }); + + return filteredColumns; +} + const rowClickFunction = computed(() => { if ($props.rowClick != undefined) return $props.rowClick; if ($props.redirect) return ({ id }) => redirectFn(id); @@ -310,8 +334,14 @@ function handleSelection({ evt, added, rows: selectedRows }, rows) { if (evt?.shiftKey && added) { const rowIndex = selectedRows[0].$index; const selectedIndexes = new Set(selected.value.map((row) => row.$index)); - for (const row of rows) { - if (row.$index == rowIndex) break; + const minIndex = selectedIndexes.size + ? Math.min(...selectedIndexes, rowIndex) + : 0; + const maxIndex = Math.max(...selectedIndexes, rowIndex); + + for (let i = minIndex; i <= maxIndex; i++) { + const row = rows[i]; + if (row.$index == rowIndex) continue; if (!selectedIndexes.has(row.$index)) { selected.value.push(row); selectedIndexes.add(row.$index); @@ -334,12 +364,11 @@ function hasEditableFormat(column) { const clickHandler = async (event) => { const clickedElement = event.target.closest('td'); - const isDateElement = event.target.closest('.q-date'); const isTimeElement = event.target.closest('.q-time'); - const isQselectDropDown = event.target.closest('.q-select__dropdown-icon'); + const isQSelectDropDown = event.target.closest('.q-select__dropdown-icon'); - if (isDateElement || isTimeElement || isQselectDropDown) return; + if (isDateElement || isTimeElement || isQSelectDropDown) return; if (clickedElement === null) { await destroyInput(editingRow.value, editingField.value); @@ -578,9 +607,24 @@ function removeTextValue(data, getChanges) { return data; } + +function handleRowClick(event, row) { + if (event.ctrlKey) return rowCtrlClickFunction.value(event, row); + if (rowClickFunction.value) rowClickFunction.value(row); +} + +const rowCtrlClickFunction = computed(() => { + if ($props.rowCtrlClick != undefined) return $props.rowCtrlClick; + if ($props.redirect) + return (evt, { id }) => { + stopEventPropagation(evt); + window.open(`/#/${$props.redirect}/${id}`, '_blank'); + }; + return () => {}; +});