rb-document-form-constructor 0.5.2 → 0.5.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,3 @@
1
+ .cursor-pointer {
2
+ cursor: pointer;
3
+ }
@@ -0,0 +1,16 @@
1
+ // DocTemplateFacetList
2
+ $rb-facet-list-border-color: $border-color !default;
3
+
4
+ // DocTemplateConstructor
5
+ $rb-doc-template-constructor-title-color: #333 !default;
6
+ $rb-doc-template-constructor-title-font-size: 16px !default;
7
+ $rb-doc-template-section-bg: #E9EAEA !default;
8
+ $rb-doc-template-constructor-form-column-border-color: #D5D5D6;
9
+
10
+ // DocTemplateFieldSidebar
11
+ $rb-doc-template-field-sidebar-font-size-lg: 1rem !default;
12
+ $rb-doc-template-field-sidebar-top: 72px !default;
13
+ $rb-doc-template-field-sidebar-close-button-left: -46px !default;
14
+
15
+ // DocForm
16
+ $rb-doc-form-font-size-lg: 1rem !default;
@@ -0,0 +1,28 @@
1
+ .rb-doc-form {
2
+ h4 {
3
+ font-weight: bold;
4
+ font-size: $rb-doc-form-font-size-lg;
5
+ }
6
+
7
+ .rb-form-section {
8
+ padding-bottom: 10px;
9
+ padding-top: 10px;
10
+ }
11
+
12
+ .rb-form-column {
13
+ flex: 1;
14
+ }
15
+
16
+ .rb-form-column:first-child {
17
+ margin-left: 0;
18
+ }
19
+
20
+ .rb-form-column:last-child {
21
+ margin-right: 0;
22
+ }
23
+
24
+ .rb-form-column {
25
+ margin-left: 10px;
26
+ margin-right: 10px;
27
+ }
28
+ }
@@ -0,0 +1,112 @@
1
+ .rb-doc-template-constructor {
2
+ height: 100%;
3
+
4
+ h4 {
5
+ color: $rb-doc-template-constructor-title-color;
6
+ font-weight: bold;
7
+ font-size: $rb-doc-template-constructor-title-font-size;
8
+ }
9
+
10
+ .rb-form-constructor {
11
+ height: 100%;
12
+ overflow-y: auto;
13
+ background-color: white;
14
+ }
15
+
16
+ .rb-constructor-toolbar {
17
+ padding: 16px 16px 16px 16px;
18
+ background-color: white;
19
+ border-bottom: 1px solid $border-color;
20
+
21
+ h4 {
22
+ margin-bottom: 0;
23
+ line-height: 38px;
24
+ margin-right: 10px;
25
+ }
26
+
27
+ .btn {
28
+ margin-left: 10px;
29
+ }
30
+ }
31
+
32
+ .rb-constructor-body {
33
+ padding: 16px;
34
+
35
+ .card {
36
+ border-width: 2px;
37
+ border-style: dashed;
38
+ background-color: $rb-doc-template-section-bg;
39
+
40
+ .card-header, .card-body {
41
+ background-color: $rb-doc-template-section-bg;
42
+ border-color: $border-color;
43
+
44
+ }
45
+ }
46
+
47
+ .rb-form-card {
48
+ margin-bottom: 20px;
49
+
50
+ .rb-form-column {
51
+ flex: 1;
52
+ }
53
+
54
+ .card-header {
55
+ border-bottom-width: 0;
56
+ display: flex;
57
+ flex-direction: row;
58
+
59
+ .rb-text {
60
+ font-size: 16px;
61
+ line-height: 24px;
62
+ font-weight: bold;
63
+ }
64
+
65
+ .rb-icon {
66
+ line-height: 24px;
67
+ font-size: 16px;
68
+ }
69
+ }
70
+ }
71
+
72
+ .rb-form-column {
73
+ .form-group:hover {
74
+ legend.col-form-label .rb-actions {
75
+ visibility: visible;
76
+ }
77
+ }
78
+
79
+ legend.col-form-label {
80
+ font-size: $font-size-base;
81
+ font-weight: bold;
82
+ margin-bottom: 12px;
83
+ display: flex;
84
+ flex-direction: row;
85
+ color: $rb-doc-template-constructor-title-color;
86
+
87
+ .rb-text {
88
+ flex: 1;
89
+ }
90
+
91
+ .rb-actions {
92
+ visibility: hidden;
93
+ }
94
+ }
95
+
96
+ .form-control:disabled,
97
+ .btn.disabled {
98
+ background-color: white;
99
+ opacity: 1;
100
+ }
101
+ }
102
+
103
+ .rb-form-column {
104
+ padding: 10px;
105
+ border: 2px dashed $rb-doc-template-constructor-form-column-border-color;
106
+ }
107
+
108
+ .rb-form-column:not(.rb-single-column) {
109
+ margin: 0 10px;
110
+ }
111
+ }
112
+ }
@@ -0,0 +1,41 @@
1
+ .rb-facets-sidebar {
2
+ height: 100%;
3
+ width: 264px;
4
+ overflow-y: auto;
5
+ background-color: white;
6
+ border-right: 1px solid $rb-facet-list-border-color;
7
+
8
+ h4 {
9
+ padding: 24px 16px 16px 16px;
10
+ }
11
+
12
+ h6 {
13
+ padding-left: 16px;
14
+ padding-right: 16px;
15
+ font-weight: 500;
16
+ }
17
+
18
+ form {
19
+ padding-left: 16px;
20
+ padding-right: 16px;
21
+ }
22
+
23
+ .rb-facet-label {
24
+ font-weight: bold;
25
+ }
26
+
27
+ .rb-facet-list {
28
+ .rb-facet {
29
+ padding: 10px 0;
30
+ }
31
+
32
+ & > .rb-facet:not(:last-child) {
33
+ border-bottom: 1px solid $rb-facet-list-border-color;
34
+ }
35
+
36
+ .list-group-item {
37
+ border-radius: 0;
38
+ border: none;
39
+ }
40
+ }
41
+ }
@@ -0,0 +1,52 @@
1
+ .rb-doc-template-field-sidebar {
2
+ .dropdown-menu.show {
3
+ max-width: 288px;
4
+ }
5
+
6
+ .b-sidebar {
7
+ top: $rb-doc-template-field-sidebar-top;
8
+ padding-bottom: $rb-doc-template-field-sidebar-top;
9
+ }
10
+
11
+ .rb-sidebar-close-btn {
12
+ opacity: 0.5;
13
+ position: absolute;
14
+ left: $rb-doc-template-field-sidebar-close-button-left;
15
+ border-radius: 0;
16
+ padding-left: 4px;
17
+ padding-right: 4px;
18
+ font-size: 16px;
19
+
20
+ .rb-icon {
21
+ font-size: 24px;
22
+ line-height: 24px;
23
+ vertical-align: middle;
24
+ }
25
+ }
26
+
27
+ form {
28
+ padding: 10px 16px;
29
+
30
+ .rb-form-section {
31
+ margin-bottom: 20px;
32
+
33
+ & > .rb-title {
34
+ font-size: $rb-doc-template-field-sidebar-font-size-lg;
35
+ font-weight: bold;
36
+ margin-bottom: 10px;
37
+ }
38
+ }
39
+ }
40
+
41
+ h4 {
42
+ margin-bottom: 0;
43
+ }
44
+
45
+ .form-group.rb-immutable .rb-text {
46
+ font-size: $rb-doc-template-field-sidebar-font-size-lg;
47
+ }
48
+
49
+ .custom-checkbox {
50
+ margin-bottom: 12px;
51
+ }
52
+ }
@@ -0,0 +1,27 @@
1
+ $rb-field-rule-btn-toolbar-bg: rgba(0, 0, 0, 0.03) !default;
2
+
3
+ .rb-field-rule-form-modal {
4
+ .modal-body {
5
+ padding: 0;
6
+
7
+ & > .card {
8
+ border: none;
9
+ border-radius: 0;
10
+ }
11
+ }
12
+
13
+ .btn-toolbar {
14
+ border-top-left-radius: $border-radius;
15
+ border-top-right-radius: $border-radius;
16
+ background-color: $rb-field-rule-btn-toolbar-bg;
17
+ padding: 10px 10px;
18
+ border-top: 1px solid $border-color;
19
+ border-left: 1px solid $border-color;
20
+ border-right: 1px solid $border-color;
21
+ }
22
+
23
+ textarea.form-control {
24
+ border-top-left-radius: 0;
25
+ border-top-right-radius: 0;
26
+ }
27
+ }
@@ -0,0 +1,7 @@
1
+ @import 'variables';
2
+ @import 'global';
3
+ @import 'components/doc-template-facet-list';
4
+ @import 'components/doc-template-field-sidebar';
5
+ @import 'components/doc-template-constructor';
6
+ @import 'components/doc-form';
7
+ @import 'components/field-rule-form-modal';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rb-document-form-constructor",
3
- "version": "0.5.2",
3
+ "version": "0.5.5",
4
4
  "description": "",
5
5
  "main": "dist/rb-document-form-constructor.ssr.js",
6
6
  "browser": "dist/rb-document-form-constructor.esm.js",
@@ -1,38 +1,45 @@
1
1
  <template>
2
2
  <b-form v-if="formConfig" class="rb-doc-form">
3
- <div v-for="(section) in formConfig.sections" :key="section.labelRu" v-if="formConfig && formConfig.sections"
4
- class="rb-form-section">
5
- <h4>{{ section.labelRu }}</h4>
3
+ <b-container v-if="formConfig && formConfig.sections"
4
+ v-for="(section) in formConfig.sections"
5
+ :key="section.labelRu"
6
6
 
7
- <div class="d-flex flex-row">
8
- <div class="rb-form-column" v-for="column in section.columns" :key="column.index">
9
- <template v-for="field in column.fields">
10
- <b-form-row :key="field.name" v-if="field.visible">
11
- <b-col lg="12">
12
- <b-form-group :state="validationState[field.name]"
13
- :invalid-feedback="validationState[`${field.name}__feedback`]"
14
- ref="inputContainer">
15
- <component v-bind:is="field.input.type"
16
- v-model="doc[field.name]"
17
- :disabled="!editable || !field.editable"
18
- :id="field.name"
19
- :state="validationState[field.name]"
20
- :ref="field.name"
21
- @input="onEventFired('input', $event, field)"
22
- @change="onEventFired('change', $event, field)"
23
- @click="onEventFired('click', $event, field)"
24
- v-bind="field.input.propsData"></component>
25
- <template #label>
26
- {{ field.labelRu }} <span v-if="showRequiredInLabel && field.required"
27
- class="text-danger">*</span>
28
- </template>
29
- </b-form-group>
30
- </b-col>
31
- </b-form-row>
32
- </template>
33
- </div>
34
- </div>
35
- </div>
7
+ class="rb-form-section">
8
+ <b-row>
9
+ <b-col lg="12">
10
+ <h4>{{section.labelRu}}</h4>
11
+ </b-col>
12
+ <template v-for="column in section.columns">
13
+ <b-col :key="column.index" :lg="getColumnSize(section)" :sm="12">
14
+ <template v-for="field in column.fields">
15
+ <b-form-row :key="field.name" v-if="field.visible">
16
+ <b-col lg="12">
17
+ <b-form-group :state="validationState[field.name]"
18
+ :invalid-feedback="validationState[`${field.name}__feedback`]"
19
+ ref="inputContainer">
20
+ <component v-bind:is="field.input.type"
21
+ v-model="doc[field.name]"
22
+ :disabled="!editable || !field.editable"
23
+ :id="field.name"
24
+ :state="validationState[field.name]"
25
+ :ref="field.name"
26
+ @input="onEventFired('input', $event, field)"
27
+ @change="onEventFired('change', $event, field)"
28
+ @click="onEventFired('click', $event, field)"
29
+ v-bind="field.input.propsData"></component>
30
+ <template #label>
31
+ {{field.labelRu}} <span v-if="showRequiredInLabel && field.required"
32
+ class="text-danger">*</span>
33
+ </template>
34
+ </b-form-group>
35
+ </b-col>
36
+ </b-form-row>
37
+ </template>
38
+ </b-col>
39
+
40
+ </template>
41
+ </b-row>
42
+ </b-container>
36
43
  </b-form>
37
44
  </template>
38
45
 
@@ -88,19 +95,14 @@
88
95
  }
89
96
  },
90
97
  isValueEmpty(fieldName) {
91
- console.info('isValueEmpty', fieldName, this.doc[fieldName]);
92
-
93
98
  if (this.doc[fieldName] == null) {
94
- console.info(`${fieldName} is empty`);
95
99
  return true;
96
100
  }
97
101
 
98
102
  if (typeOf(this.doc[fieldName] === 'string') && this.doc[fieldName] === '') {
99
- console.info(`${fieldName} is empty`);
100
103
  return true;
101
104
  }
102
105
 
103
- console.info(`${fieldName} is not empty`);
104
106
  return false;
105
107
  },
106
108
  validate() {
@@ -130,18 +132,28 @@
130
132
  }
131
133
 
132
134
  return true;
133
- }
135
+ },
136
+ getColumnSize(section) {
137
+ const MAX_COLUMN_SIZE = 12;
138
+ if (!section || !section.columnCount) {
139
+ return MAX_COLUMN_SIZE;
140
+ }
141
+
142
+ let colSize = Math.floor(MAX_COLUMN_SIZE / section.columnCount);
143
+ console.info("colSize", colSize);
144
+ return colSize;
145
+ },
134
146
  },
135
147
  created() {
136
148
  if (this.applyDefaultValues) {
137
149
  this.formConfig.sections.forEach(r => {
138
150
  r.columns.forEach(c => {
139
151
  c.fields.forEach(f => {
140
- let defValue = null;
152
+ let defValue;
141
153
  if (this.defaultValue && typeOf(f.defaultValue) === 'function') {
142
154
  defValue = f.defaultValue();
143
155
  } else {
144
- defValue = this.defaultValue == null ? null : f.defaultValue;
156
+ defValue = f.defaultValue == null ? null : f.defaultValue;
145
157
  }
146
158
 
147
159
  this.$set(
@@ -206,7 +206,7 @@
206
206
  multiple() {
207
207
  let input = UtFormConstructor.getDefaultInput(this.field);
208
208
  this.currentInputName = input.name;
209
- }
209
+ },
210
210
  },
211
211
  methods: {
212
212
  hide() {