Commits (3)
This diff is collapsed.
{
"name": "@coscine/form-generator",
"version": "1.10.0",
"version": "1.10.1",
"main": "./dist/index.js",
"module": "dist/index.esm.js",
"types": "dist/index.d.ts",
......@@ -36,7 +36,7 @@
"@coscine/app-util": "^1.6.0",
"@types/jquery": "^3.5.2",
"@types/vuelidate": "^0.7.13",
"bootstrap-vue": "^2.17.3",
"bootstrap-vue": "^2.20.1",
"jquery": "^3.5.1",
"rdf-ext": "^1.3.0",
"rdf-parse": "^1.5.0",
......@@ -48,6 +48,7 @@
"vuelidate": "^0.7.5"
},
"devDependencies": {
"@hutson/semantic-delivery-gitlab": "^9.1.0",
"@semantic-release/commit-analyzer": "^8.0.1",
"@semantic-release/git": "^9.0.0",
"@semantic-release/gitlab": "^6.0.5",
......@@ -66,8 +67,7 @@
"prettier": "^2.1.2",
"rollup-plugin-typescript2": "^0.27.3",
"rollup-plugin-vue": "^5.1.9",
"semantic-release": "^17.1.2",
"@hutson/semantic-delivery-gitlab": "^9.1.0",
"semantic-release": "^17.3.0",
"tslint": "^6.1.3",
"tslint-config-prettier": "^1.18.0",
"tslint-config-standard": "^9.0.0",
......
......@@ -14,6 +14,7 @@
:languageLocale="languageLocale"
:v="$v"
:errorMessages="errorMessages"
@input="input"
/>
</div>
</div>
......@@ -23,7 +24,6 @@
import Vue from 'vue';
import { validationMixin } from 'vuelidate';
import { required, minLength, maxLength } from 'vuelidate/lib/validators';
import { MetadataApi } from '@coscine/api-connection';
import VueI18n from 'vue-i18n';
......@@ -131,11 +131,15 @@ export default Vue.extend({
this.handleApplicationProfiles();
},
formData() {
this.input();
this.$v.$reset();
this.createValidations();
},
},
methods: {
input() {
this.$emit('input', this.formData);
},
createValidations() {
const me = this;
const validator = {} as any;
......@@ -144,6 +148,7 @@ export default Vue.extend({
$each: {
value: {
async shaclValidated(value: any) {
me.input();
// A debounce has been implemented based on the nodename
if (me.timeouts[nodename]) clearTimeout(me.timeouts[nodename]);
return new Promise((resolve, reject) => {
......
......@@ -62,27 +62,30 @@ export default Vue.extend({
}
},
mounted() {
MetadataApi.getClassInstances(
this.projectId,
this.class,
(response: any) => {
if (
Array.isArray(response.data[this.languageCode]) &&
response.data[this.languageCode].length === 0
) {
if ((typeof coscine !== "undefined") && (typeof (coscine as any).authorization !== "undefined") && (typeof (coscine as any).authorization.bearer !== "undefined")) {
MetadataApi.getClassInstances(
this.projectId,
this.class,
(response: any) => {
if (
Array.isArray(response.data.en) &&
response.data.en.length !== 0
Array.isArray(response.data[this.languageCode]) &&
response.data[this.languageCode].length === 0
) {
this.selectableOptions = response.data.en;
if (
Array.isArray(response.data.en) &&
response.data.en.length !== 0
) {
this.selectableOptions = response.data.en;
} else {
this.selectableOptions = response.data.de;
}
} else {
this.selectableOptions = response.data.de;
this.selectableOptions = response.data[this.languageCode];
}
} else {
this.selectableOptions = response.data[this.languageCode];
this.loadData();
}
this.loadData();
});
);
}
if (this.fixedValueMode) {
this.updateFixedValues();
}
......
<template>
<div id="datepicker">
<b-form-datepicker
:id="cssId"
size="sm"
v-model="selectedDate"
:locale="languageCode"
:date-format-options="{ year: 'numeric', month: 'long', day: 'numeric' }"
:disabled="disabledMode || locked"
@input="updateFixedValuesOverwrite"
:required="required"
calendar-width="100%"
></b-form-datepicker>
</div>
<b-form-datepicker
:id="cssId"
class="formgeneratordatepicker"
size="sm"
v-model="selectedDate"
:locale="languageCode"
:disabled="disabledMode || locked"
@input="input"
:required="required"
calendar-width="100%"
start-weekday="1"
:state="v.formData[nodeName] && v.formData[nodeName].$each[0]['value'].$dirty ? !v.formData[nodeName].$each[0]['value'].$error : null"
/>
</template>
<script lang="ts">
......@@ -34,12 +34,11 @@ export default Vue.extend({
);
if (this.fixedValueMode) {
this.updateFixedValuesOverwrite();
this.input();
}
},
data() {
return {
formatDate: '',
selectedDate: '',
};
},
......@@ -66,13 +65,15 @@ export default Vue.extend({
if (this.fixedValueMode) {
return;
}
this.selectedDate = new Date().toString();
const today = new Date();
const dd = String(today.getDate()).padStart(2, '0');
const mm = String(today.getMonth() + 1).padStart(2, '0'); // January is 0!
const yyyy = today.getFullYear();
this.selectedDate = yyyy + '-' + mm + '-' + dd;
} else if (this.formData[this.nodeName][0]['value'] === '') {
this.selectedDate = '';
} else {
this.selectedDate =
this.formData[this.nodeName][0]['value']
;
this.selectedDate = this.formData[this.nodeName][0]['value'];
}
this.$set(
......@@ -82,7 +83,7 @@ export default Vue.extend({
);
}
},
updateFixedValuesOverwrite() {
input() {
FieldReader.setField(
this.formData,
this.v,
......@@ -92,21 +93,28 @@ export default Vue.extend({
);
this.updateFixedValues();
},
onContext(ctx: any) {
this.formatDate= ctx.selectedFormatted
},
},
});
</script>
<style>
#datepicker .btn {
margin: 0;
background-color: #eceded;
border: 1px solid #cfd1d2;
border-radius: 0;
}
.formgeneratordatepicker label {
display: flex;
align-items: center;
}
.formgeneratordatepicker div.is-valid {
background-image: unset;
}
.formgeneratordatepicker footer {
display: none;
}
.formgeneratordatepicker button {
min-width: unset;
}
.b-calendar button {
min-width: unset;
}
</style>
<style scoped></style>
<style scoped>
</style>
......@@ -74,15 +74,17 @@ export default Vue.extend({
if (!this.fixedValueMode) {
if (this.checkDataField(this.formData, this.nodeName)) {
if (this.formData[this.nodeName][0]['value'] === '{ME}') {
UserApi.getUser((response: any) => {
this.$set(
this.formData[this.nodeName][0],
'value',
response.data.displayName
);
this.textValue = this.formData[this.nodeName][0]['value'];
this.$forceUpdate();
});
if ((typeof coscine !== "undefined") && (typeof (coscine as any).authorization !== "undefined") && (typeof (coscine as any).authorization.bearer !== "undefined")) {
UserApi.getUser((response: any) => {
this.$set(
this.formData[this.nodeName][0],
'value',
response.data.displayName
);
this.textValue = this.formData[this.nodeName][0]['value'];
this.$forceUpdate();
});
}
}
}
}
......
......@@ -74,15 +74,17 @@ export default Vue.extend({
if (!this.fixedValueMode) {
if (this.checkDataField(this.formData, this.nodeName)) {
if (this.formData[this.nodeName][0]['value'] === '{ME}') {
UserApi.getUser((response: any) => {
this.$set(
this.formData[this.nodeName][0],
'value',
response.data.displayName
);
this.textValue = this.formData[this.nodeName][0]['value'];
this.$forceUpdate();
});
if ((typeof coscine !== "undefined") && (typeof (coscine as any).authorization !== "undefined") && (typeof (coscine as any).authorization.bearer !== "undefined")) {
UserApi.getUser((response: any) => {
this.$set(
this.formData[this.nodeName][0],
'value',
response.data.displayName
);
this.textValue = this.formData[this.nodeName][0]['value'];
this.$forceUpdate();
});
}
}
}
}
......
......@@ -248,9 +248,11 @@ export default Vue.extend({
FieldReader.getObject(this.formFieldInformation, 'http://www.w3.org/ns/shacl#minCount')[
'value'
] >= 1;
this.$emit('input');
},
computed: {
cssProps() : any {
cssProps(): any {
return {
'--wrapperInputWidth': (this.fixedValueMode) ? 'calc(100% - 121px - 1rem)' : '100%',
'--wrapperInputRightMargin': (this.fixedValueMode) ? '1rem' : '0rem',
......