Skip to content

Commit 035b456

Browse files
fix merge conflicts
2 parents e770282 + 75a0ae1 commit 035b456

File tree

15 files changed

+222
-13
lines changed

15 files changed

+222
-13
lines changed

css/builder.css

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1204,10 +1204,6 @@ form hr {
12041204
border: 0;
12051205
}
12061206

1207-
#data-source-provider {
1208-
margin-bottom: -10px;
1209-
}
1210-
12111207
.columns-notification .btn-generate-columns {
12121208
margin-top: 10px;
12131209
}
@@ -1396,3 +1392,11 @@ form hr {
13961392
.form-group.fl-typeahead .selectize-input.focus {
13971393
border-color: #00abd1;
13981394
}
1395+
1396+
.timeStamp {
1397+
font-size: 13px;
1398+
text-align: center;
1399+
color: #514f4f;
1400+
padding: 10px 10px;
1401+
background-color: #eaeaea;
1402+
}

css/form.css

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1095,6 +1095,22 @@ html[dir="rtl"] .radio.radio-icon input[type="radio"] + label > span.check {
10951095
border-radius: 4px;
10961096
}
10971097

1098+
.tox .tox-toolbar__primary {
1099+
justify-content: space-between;
1100+
}
1101+
1102+
.tox:not(.tox-tinymce-inline) .tox-editor-header {
1103+
padding: 4px !important;
1104+
}
1105+
1106+
.tox .tox-toolbar__group {
1107+
padding: 0px !important;
1108+
}
1109+
1110+
.tox.tox-tinymce {
1111+
min-height: 130px !important;
1112+
}
1113+
10981114
@media screen and (max-width: 1280px) {
10991115
.tox-toolbar__primary {
11001116
justify-content: space-between;
@@ -1647,3 +1663,11 @@ form hr {
16471663
background-color: #e0e0e0;
16481664
font-weight: bold;
16491665
}
1666+
1667+
.timeStamp {
1668+
font-size: 16px;
1669+
text-align: center;
1670+
color: #514f4f;
1671+
padding: 10px 10px;
1672+
background-color: #eaeaea;
1673+
}

js/build.templates.js

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/components/timeStamp.js

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
Fliplet.FormBuilder.field('timeStamp', {
2+
name: 'Time Stamp',
3+
category: 'Date & time',
4+
props: {
5+
value: {
6+
type: Object
7+
},
8+
placeholder: {
9+
type: String
10+
},
11+
description: {
12+
type: String
13+
},
14+
createdAt: {
15+
type: Boolean,
16+
default: true
17+
},
18+
updatedAt: {
19+
type: Boolean,
20+
default: true
21+
},
22+
showLabel: {
23+
type: Boolean,
24+
default: false
25+
},
26+
label: undefined
27+
},
28+
created: function() {
29+
Fliplet.Hooks.on('afterFormSubmit', this.afterFormSubmit);
30+
},
31+
destroyed: function() {
32+
Fliplet.Hooks.off('afterFormSubmit', this.afterFormSubmit);
33+
},
34+
mounted: function() {
35+
this.value = {
36+
createdAt: this.createdAt,
37+
updatedAt: this.updatedAt
38+
};
39+
this.$emit('_input', this.name, this.value);
40+
},
41+
watch: {
42+
createdAt: function(val) {
43+
this.value = {
44+
createdAt: val,
45+
updatedAt: this.updatedAt
46+
};
47+
this.$emit('_input', this.name, this.value);
48+
},
49+
updatedAt: function(val) {
50+
this.value = {
51+
createdAt: this.createdAt,
52+
updatedAt: val
53+
};
54+
this.$emit('_input', this.name, this.value);
55+
}
56+
},
57+
methods: {
58+
afterFormSubmit: async function(data, form) {
59+
const fields = form.$instance.fields;
60+
const hasTimeStamp = fields.some(field => field._type === 'flTimeStamp');
61+
62+
if (!hasTimeStamp) {
63+
return;
64+
}
65+
66+
const dataSourceId = data.result && data.result.dataSourceId;
67+
68+
if (!dataSourceId) {
69+
return;
70+
}
71+
72+
const connection = await Fliplet.DataSources.connect(dataSourceId);
73+
74+
if (data.result.createdAt !== data.result.updatedAt && this.updatedAt && this.createdAt) {
75+
connection.update(data.result.id, {
76+
'Created at': data.result.createdAt,
77+
'Last updated': data.result.updatedAt
78+
});
79+
} else if (data.result.createdAt !== data.result.updatedAt && this.updatedAt) {
80+
connection.update(data.result.id, {
81+
'Last updated': data.result.updatedAt
82+
});
83+
} else if (this.createdAt) {
84+
connection.update(data.result.id, {
85+
'Created at': data.result.createdAt
86+
});
87+
}
88+
}
89+
}
90+
});

js/components/wysiwyg.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ Fliplet.FormBuilder.field('wysiwyg', {
7373
},
7474
mounted: function() {
7575
var $vm = this;
76-
var lineHeight = 40;
76+
var lineHeight = 55;
7777

7878
this.tinymceId = _.kebabCase(this.name) + '-' + $(this.$refs.textarea).parents('[data-form-builder-id]').data('formBuilderId');
7979

@@ -97,7 +97,7 @@ Fliplet.FormBuilder.field('wysiwyg', {
9797
: [
9898
'undo redo',
9999
'bold italic underline',
100-
'alignleft aligncenter alignright alignjustify | bullist numlist outdent indent',
100+
'alignleft aligncenter alignright alignjustify | bullist numlist | outdent indent',
101101
'ltr rtl | link | removeformat code fullscreen',
102102
'table tabledelete | tableprops tablerowprops tablecellprops',
103103
'tableinsertrowbefore tableinsertrowafter tabledeleterow | tableinsertcolbefore tableinsertcolafter tabledeletecol'

js/configurations/timeStamp.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fliplet.FormBuilder.configuration('timeStamp');

js/interface.templates.js

Lines changed: 5 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/libs/builder.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -960,6 +960,18 @@ Fliplet().then(function() {
960960

961961
break;
962962

963+
case 'flTimeStamp':
964+
if (field.createdAt && !field.updatedAt) {
965+
fieldNames.push('Created at');
966+
} else if (!field.createdAt && field.updatedAt) {
967+
fieldNames.push('Last updated');
968+
} else {
969+
fieldNames.push('Created at');
970+
fieldNames.push('Last updated');
971+
}
972+
973+
break;
974+
963975
case 'flMatrix':
964976
_.forEach(field.rowOptions, function(row) {
965977
var val = row.id ? row.id : row.label;

js/libs/core.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -752,6 +752,15 @@ Fliplet.FormBuilder = (function() {
752752

753753
break;
754754

755+
case 'flTimeStamp':
756+
if (!this.updatedAt && !this.createdAt) {
757+
_.assignIn(this.errors, {
758+
timeStampOption: 'Select at least one timestamp saving option to continue'
759+
});
760+
}
761+
762+
break;
763+
755764
default:
756765
// nothing
757766
}

js/libs/form.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1180,6 +1180,15 @@ Fliplet().then(function() {
11801180
} else if (type === 'flGeolocation') {
11811181
appendField(field.name, value ? value[0] : null);
11821182
appendField(`${field.name} (accuracy)`, value ? value[1] : null);
1183+
} else if (type === 'flTimeStamp') {
1184+
if (value.createdAt && !value.updatedAt) {
1185+
appendField('Created at', new Date().toISOString());
1186+
} else if (!value.createdAt && value.updatedAt) {
1187+
appendField('Last updated', '');
1188+
} else if (value.createdAt && value.updatedAt) {
1189+
appendField('Created at', new Date().toISOString());
1190+
appendField('Last updated', '');
1191+
}
11831192
} else {
11841193
// Other inputs
11851194
appendField(field.name, value);

0 commit comments

Comments
 (0)