alchemy-form 0.2.5 → 0.2.7

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.
Files changed (122) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/README.md +0 -0
  3. package/assets/stylesheets/form/alchemy_form.scss +0 -0
  4. package/assets/stylesheets/form/elements/_button.scss +0 -0
  5. package/assets/stylesheets/form/elements/_code_input.scss +0 -0
  6. package/assets/stylesheets/form/elements/_feedback_input.scss +0 -0
  7. package/assets/stylesheets/form/elements/_field.scss +1 -1
  8. package/assets/stylesheets/form/elements/_field_array.scss +0 -0
  9. package/assets/stylesheets/form/elements/_field_translatable.scss +0 -0
  10. package/assets/stylesheets/form/elements/_form.scss +0 -0
  11. package/assets/stylesheets/form/elements/_pager.scss +0 -0
  12. package/assets/stylesheets/form/elements/_pathway.scss +56 -0
  13. package/assets/stylesheets/form/elements/_query_builder.scss +0 -0
  14. package/assets/stylesheets/form/elements/_select.scss +0 -0
  15. package/assets/stylesheets/form/elements/_state.scss +0 -0
  16. package/assets/stylesheets/form/elements/_table.scss +0 -0
  17. package/assets/stylesheets/form/elements/_tabs.scss +0 -0
  18. package/assets/stylesheets/form/elements/_toggle.scss +11 -5
  19. package/assets/stylesheets/form/elements/index.scss +2 -1
  20. package/assets/stylesheets/form/general/_colors.scss +0 -0
  21. package/assets/stylesheets/form/general/_textsizes.scss +0 -0
  22. package/assets/stylesheets/form/general/index.scss +0 -0
  23. package/config/routes.js +0 -0
  24. package/controller/form_api_controller.js +0 -0
  25. package/element/10_alchemy_field_custom.js +0 -0
  26. package/element/10_dataprovider.js +0 -0
  27. package/element/15_alchemy_field_entry.js +0 -0
  28. package/element/20_query_builder_base.js +0 -0
  29. package/element/25_query_builder_data.js +0 -2
  30. package/element/30_tab_base.js +0 -0
  31. package/element/40_stateful.js +0 -0
  32. package/element/al_button.js +0 -0
  33. package/element/al_code_input.js +0 -0
  34. package/element/al_field.js +35 -4
  35. package/element/al_field_array.js +0 -0
  36. package/element/al_field_array_entry.js +0 -0
  37. package/element/al_field_schema.js +14 -1
  38. package/element/al_field_translatable.js +0 -0
  39. package/element/al_field_translatable_entry.js +0 -0
  40. package/element/al_label.js +0 -0
  41. package/element/al_number_input.js +0 -0
  42. package/element/al_pager.js +0 -0
  43. package/element/al_password_input.js +0 -0
  44. package/element/al_pathway.js +82 -0
  45. package/element/al_pathway_selection.js +690 -0
  46. package/element/al_query_builder.js +0 -0
  47. package/element/al_query_builder_entry.js +18 -3
  48. package/element/al_query_builder_group.js +0 -0
  49. package/element/al_query_builder_value.js +0 -0
  50. package/element/al_query_builder_variable.js +0 -0
  51. package/element/al_select.js +6 -2
  52. package/element/al_select_item.js +0 -0
  53. package/element/al_state.js +0 -0
  54. package/element/al_tab_button.js +0 -0
  55. package/element/al_tab_context.js +0 -0
  56. package/element/al_tab_list.js +0 -0
  57. package/element/al_tab_panel.js +0 -0
  58. package/element/al_table.js +0 -0
  59. package/element/al_toggle.js +0 -0
  60. package/helper/form_actions/00_form_action.js +0 -0
  61. package/helper/form_actions/url_action.js +0 -0
  62. package/helper/pathway/leaf.js +174 -0
  63. package/helper/query_builder_ns.js +0 -0
  64. package/helper/query_builder_variable_definition/00_variable_definition.js +0 -0
  65. package/helper/query_builder_variable_definition/boolean_variable_definition.js +0 -0
  66. package/helper/query_builder_variable_definition/list_variable_definition.js +0 -0
  67. package/helper/query_builder_variable_definition/number_variable_definition.js +0 -0
  68. package/helper/query_builder_variable_definition/string_variable_definition.js +0 -0
  69. package/helper_field/query_builder_assignment.js +0 -0
  70. package/helper_field/query_builder_field.js +0 -0
  71. package/helper_field/query_builder_value.js +0 -0
  72. package/helper_field/query_builder_variable.js +0 -0
  73. package/package.json +3 -3
  74. package/view/form/elements/al_pathway.hwk +5 -0
  75. package/view/form/elements/al_pathway_selection.hwk +10 -0
  76. package/view/form/elements/alchemy_button.hwk +0 -0
  77. package/view/form/elements/alchemy_field_array.hwk +0 -0
  78. package/view/form/elements/alchemy_field_array_entry.hwk +0 -0
  79. package/view/form/elements/alchemy_field_schema.hwk +0 -0
  80. package/view/form/elements/alchemy_field_translatable.hwk +0 -0
  81. package/view/form/elements/alchemy_field_translatable_entry.hwk +0 -0
  82. package/view/form/elements/alchemy_select.hwk +0 -0
  83. package/view/form/elements/alchemy_select_item.hwk +0 -0
  84. package/view/form/elements/alchemy_toggle.hwk +2 -0
  85. package/view/form/elements/code_input.hwk +0 -0
  86. package/view/form/elements/number_input.hwk +0 -0
  87. package/view/form/elements/password_input.hwk +0 -0
  88. package/view/form/elements/query_builder.hwk +0 -0
  89. package/view/form/elements/query_builder_entry.hwk +0 -0
  90. package/view/form/elements/query_builder_group.hwk +0 -0
  91. package/view/form/elements/query_builder_value.hwk +0 -0
  92. package/view/form/elements/query_builder_variable.hwk +0 -0
  93. package/view/form/inputs/edit/belongs_to.hwk +0 -0
  94. package/view/form/inputs/edit/boolean.hwk +0 -0
  95. package/view/form/inputs/edit/date.hwk +0 -0
  96. package/view/form/inputs/edit/datetime.hwk +0 -0
  97. package/view/form/inputs/edit/enum.hwk +0 -0
  98. package/view/form/inputs/edit/has_and_belongs_to_many.hwk +0 -0
  99. package/view/form/inputs/edit/has_one_parent.hwk +0 -0
  100. package/view/form/inputs/edit/html.hwk +0 -0
  101. package/view/form/inputs/edit/number.hwk +0 -0
  102. package/view/form/inputs/edit/query_builder.hwk +0 -0
  103. package/view/form/inputs/edit/query_builder_assignment.hwk +0 -0
  104. package/view/form/inputs/edit/query_builder_value.hwk +0 -0
  105. package/view/form/inputs/edit/query_builder_variable.hwk +0 -0
  106. package/view/form/inputs/edit/schema.hwk +0 -0
  107. package/view/form/inputs/edit/sourcecode.hwk +0 -0
  108. package/view/form/inputs/edit/string.hwk +2 -0
  109. package/view/form/inputs/edit/text.hwk +1 -1
  110. package/view/form/inputs/edit_inline/boolean.hwk +0 -0
  111. package/view/form/inputs/view/datetime.hwk +0 -0
  112. package/view/form/inputs/view/string.hwk +0 -0
  113. package/view/form/inputs/view_inline/boolean.hwk +0 -0
  114. package/view/form/inputs/view_inline/date.hwk +1 -4
  115. package/view/form/inputs/view_inline/datetime.hwk +25 -5
  116. package/view/form/inputs/view_inline/enum.hwk +0 -0
  117. package/view/form/inputs/view_inline/objectid.hwk +0 -0
  118. package/view/form/inputs/view_inline/string.hwk +0 -0
  119. package/view/form/select/qb_item.hwk +0 -0
  120. package/view/form/wrappers/default/default.hwk +2 -2
  121. package/view/form/wrappers/edit_inline/default.hwk +0 -0
  122. package/view/form/wrappers/view_inline/default.hwk +0 -0
package/CHANGELOG.md CHANGED
@@ -1,3 +1,19 @@
1
+ ## 0.2.7 (2023-10-05)
2
+
3
+ * If a `al-field` element is assigned a `Field` instance to its `config` property without a parent `schema` property, it will be stored in its `assigned_data` property
4
+ * Make sure string fields use the `text` input type instead of `string` in some cases
5
+ * Automatically add the `does-not-expand` css class to `al-toggle` element
6
+ * Improve `al-toggle` styling
7
+ * Store a `al-field` element's applied options in the new `applied_options` property, so it can be used inside the view templates too
8
+ * Use relative (time-ago) dates by default for showing date/datetime fields inline
9
+
10
+ ## 0.2.6 (2023-06-17)
11
+
12
+ * Fix `al-field-schema` element not being able to get schema of an arrayable field
13
+ * Add `Pathway` system for faceted breadcrumbs
14
+ * Allow `al-select` to take in simple arrays as data
15
+ * Allow getting the current operator in a query builder entry
16
+
1
17
  ## 0.2.5 (2023-04-20)
2
18
 
3
19
  * Add more configuration to `al-code-input`
package/README.md CHANGED
File without changes
File without changes
File without changes
File without changes
@@ -5,7 +5,7 @@ al-field {
5
5
 
6
6
  .field {
7
7
  display: flex;
8
- justify-content: center;
8
+ justify-content: flex-start;
9
9
  }
10
10
 
11
11
  .boolean-wrapper {
File without changes
File without changes
@@ -0,0 +1,56 @@
1
+ al-pathway {
2
+ display: flex;
3
+ }
4
+
5
+ al-pathway-selection {
6
+ display: flex;
7
+ gap: 1rem;
8
+
9
+ & > .leaf-info {
10
+ border-radius: 5px;
11
+ padding: 10px;
12
+ cursor: pointer;
13
+
14
+ background-color: var(--pathway-leaf-bg, rgb(31, 41, 55));
15
+ color: var(--pathway-leaf-color, rgb(255, 255, 255));
16
+
17
+ &:hover {
18
+ background-color: var(--pathway-leaf-hover-bg, rgb(56, 69, 85));
19
+ }
20
+ }
21
+ }
22
+
23
+
24
+ .al-pathway-leaf-dropdown {
25
+ background-color: var(--pathway-leaf-option-selection-bg, rgb(55, 65, 81));
26
+ color: var(--pathway-leaf-color, rgb(255, 255, 255));
27
+ display: flex;
28
+ border-radius: 5px;
29
+
30
+ .al-pathway-select-leaf-type,
31
+ .al-pathway-select-leaf-value {
32
+ padding: 10px 0;
33
+ }
34
+
35
+ .al-pathway-select-leaf-type {
36
+ background-color: rgba(255, 255, 255, 0.2);
37
+ }
38
+
39
+ ul {
40
+ list-style: none;
41
+ margin: 0;
42
+ padding: 0;
43
+
44
+ li {
45
+ padding: 15px 25px;
46
+ cursor: pointer;
47
+
48
+ &:hover {
49
+ background-color: var(--pathway-leaf-option-selection-hover-bg, rgb(69, 84, 101));
50
+ }
51
+ }
52
+ }
53
+
54
+
55
+
56
+ }
File without changes
File without changes
File without changes
File without changes
@@ -2,6 +2,7 @@ al-toggle {
2
2
  display: flex;
3
3
  position: relative;
4
4
  align-items: center;
5
+ cursor: pointer;
5
6
 
6
7
  input {
7
8
  opacity: 0;
@@ -14,7 +15,7 @@ al-toggle {
14
15
  background-color: #20c05b;
15
16
 
16
17
  &:before {
17
- content: attr(data-unchecked);
18
+ content: " ";
18
19
  left: 0;
19
20
  }
20
21
 
@@ -36,8 +37,9 @@ al-toggle {
36
37
  border-radius: 4px;
37
38
  min-width: 134px;
38
39
 
40
+ box-shadow: 0px 0px 2px rgba(0,0,0,0.3);
39
41
  transition: background-color 0.3s cubic-bezier(0, 1, 0.5, 1);
40
- background: #848484;
42
+ background: #b7b7b7;
41
43
  position: relative;
42
44
 
43
45
  &:before,
@@ -48,9 +50,9 @@ al-toggle {
48
50
  }
49
51
 
50
52
  &:before {
51
- content: attr(data-checked);
53
+ content: " ";
52
54
  left: 67px;
53
- font-size: 12px;
55
+ font-size: 14px;
54
56
  line-height: 36px;
55
57
  width: 67px;
56
58
  padding: 0 12px;
@@ -65,11 +67,15 @@ al-toggle {
65
67
 
66
68
  &:after {
67
69
  content: attr(data-unchecked);
70
+ display: flex;
71
+ justify-content: center;
72
+ align-items: center;
73
+ height: calc(100% - 4px);
74
+
68
75
  top: 2px;
69
76
  left: 2px;
70
77
  border-radius: 2px;
71
78
  width: 65px;
72
- line-height: 32px;
73
79
  font-size: 12px;
74
80
  font-weight: bold;
75
81
 
@@ -11,4 +11,5 @@
11
11
  @import "_state.scss";
12
12
  @import "_table.scss";
13
13
  @import "_toggle.scss";
14
- @import "_tabs.scss";
14
+ @import "_tabs.scss";
15
+ @import "_pathway.scss";
File without changes
File without changes
File without changes
package/config/routes.js CHANGED
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -133,7 +133,5 @@ QueryBuilderData.setMethod(async function loadVariableData(config) {
133
133
  }
134
134
  }
135
135
 
136
- console.log('Got loadvariable data:', result);
137
-
138
136
  return result;
139
137
  });
File without changes
File without changes
File without changes
File without changes
@@ -88,6 +88,15 @@ Field.setAttribute('readonly', {boolean: true});
88
88
  */
89
89
  Field.setAssignedProperty('widget_settings');
90
90
 
91
+ /**
92
+ * Applied options
93
+ *
94
+ * @author Jelle De Loecker <jelle@elevenways.be>
95
+ * @since 0.2.7
96
+ * @version 0.2.7
97
+ */
98
+ Field.setAssignedProperty('applied_options');
99
+
91
100
  /**
92
101
  * The placeholder
93
102
  *
@@ -151,10 +160,22 @@ Field.enforceProperty(function alchemy_field_schema(new_value, old_value) {
151
160
  *
152
161
  * @author Jelle De Loecker <jelle@elevenways.be>
153
162
  * @since 0.1.0
154
- * @version 0.1.8
163
+ * @version 0.2.7
155
164
  */
156
165
  Field.enforceProperty(function config(new_value, old_value) {
157
166
 
167
+ // If an explicit field is set without a schema,
168
+ // we need to remember it for serializing purposes
169
+ if (new_value && !new_value.schema) {
170
+ this.assigned_data.field_config = new_value;
171
+ }
172
+
173
+ // See if there is a rememberd field available
174
+ if (!new_value && this.assigned_data?.field_config) {
175
+ new_value = this.assigned_data.field_config;
176
+ }
177
+
178
+ // There is no remembered field, so check the schema
158
179
  if (!new_value && this.field_name) {
159
180
 
160
181
  let schema = this.schema;
@@ -590,7 +611,7 @@ Field.setProperty(function value() {
590
611
  *
591
612
  * @author Jelle De Loecker <jelle@elevenways.be>
592
613
  * @since 0.1.12
593
- * @version 0.1.12
614
+ * @version 0.2.7
594
615
  *
595
616
  * @param {Object} options
596
617
  */
@@ -632,6 +653,7 @@ Field.setMethod(function applyOptions(options) {
632
653
  this.field_title = options.title;
633
654
  }
634
655
 
656
+ this.applied_options = options;
635
657
  });
636
658
 
637
659
  /**
@@ -824,10 +846,14 @@ Field.setMethod(async function loadData(config, element) {
824
846
 
825
847
  if (field) {
826
848
 
849
+ console.log('Loading data...', config, element);
850
+
827
851
  let result;
828
852
 
829
853
  if (typeof field.loadData == 'function') {
830
854
 
855
+ console.log(' -- Using loadData of', field);
856
+
831
857
  try {
832
858
  result = await field.loadData(config, element);
833
859
  } catch (err) {
@@ -840,17 +866,22 @@ Field.setMethod(async function loadData(config, element) {
840
866
  }
841
867
  }
842
868
 
869
+ let model = field.parent_schema?.model_name,
870
+ assoc_model = field.options?.model_name || field.options?.modelName;
871
+
843
872
  let resource_options = {
844
873
  name : 'FormApi#related',
845
874
  post : true,
846
875
  body : {
847
876
  field : field.name,
848
- model : field.parent_schema.model_name,
849
- assoc_model : field.options.modelName,
877
+ model : model,
878
+ assoc_model : assoc_model,
850
879
  config : config,
851
880
  }
852
881
  };
853
882
 
883
+ console.log('Resource options:', resource_options)
884
+
854
885
  if (this.data_src) {
855
886
  resource_options.name = this.data_src;
856
887
  }
File without changes
File without changes
@@ -21,7 +21,7 @@ FieldSchema.setTemplateFile('form/elements/alchemy_field_schema');
21
21
  *
22
22
  * @author Jelle De Loecker <jelle@elevenways.be>
23
23
  * @since 0.1.0
24
- * @version 0.2.4
24
+ * @version 0.2.6
25
25
  */
26
26
  FieldSchema.setProperty(function schema() {
27
27
 
@@ -32,6 +32,8 @@ FieldSchema.setProperty(function schema() {
32
32
 
33
33
  let schema = field.options.schema;
34
34
 
35
+ // If the schema is a string, it's actually a reference to another field
36
+ // that *should* contain the schema.
35
37
  if (typeof schema == 'string') {
36
38
 
37
39
  let parent_schema_value;
@@ -53,6 +55,17 @@ FieldSchema.setProperty(function schema() {
53
55
  parent_schema_value = record_value;
54
56
  }
55
57
 
58
+ // If this field is inside an array, get the index
59
+ let array_entry_element = field_element.queryParents('al-field-array-entry');
60
+ if (array_entry_element) {
61
+ let index = array_entry_element.index;
62
+
63
+ // If it has an index, get the value at that index
64
+ if (index != null && Array.isArray(parent_schema_value)) {
65
+ parent_schema_value = parent_schema_value[index];
66
+ }
67
+ }
68
+
56
69
  return field.getSubschema(parent_schema_value, schema)
57
70
  }
58
71
 
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -0,0 +1,82 @@
1
+ /**
2
+ * The al-pathway element
3
+ *
4
+ * @author Jelle De Loecker <jelle@elevenways.be>
5
+ * @since 0.2.6
6
+ * @version 0.2.6
7
+ */
8
+ const Pathway = Function.inherits('Alchemy.Element.Form.Base', 'Pathway');
9
+
10
+ /**
11
+ * The hawkejs template to use
12
+ *
13
+ * @author Jelle De Loecker <jelle@elevenways.be>
14
+ * @since 0.2.6
15
+ * @version 0.2.6
16
+ */
17
+ Pathway.setTemplateFile('form/elements/al_pathway');
18
+
19
+ /**
20
+ * The root leaf property
21
+ *
22
+ * @author Jelle De Loecker <jelle@elevenways.be>
23
+ * @since 0.2.6
24
+ * @version 0.2.6
25
+ */
26
+ Pathway.setAssignedProperty('rootleaf');
27
+
28
+ /**
29
+ * The current value
30
+ *
31
+ * @author Jelle De Loecker <jelle@elevenways.be>
32
+ * @since 0.2.6
33
+ * @version 0.2.6
34
+ */
35
+ Pathway.setAssignedProperty(function value(val) {
36
+
37
+ let new_val = this.getValue();
38
+
39
+ if (new_val) {
40
+ return new_val;
41
+ }
42
+
43
+ return val;
44
+ }, function setValue(val) {
45
+
46
+ let child = this.querySelector('.al-pathway-selection-root');
47
+
48
+ if (child) {
49
+ child.value = val;
50
+ }
51
+
52
+ });
53
+
54
+ /**
55
+ * Get the current value
56
+ *
57
+ * @author Jelle De Loecker <jelle@elevenways.be>
58
+ * @since 0.2.6
59
+ * @version 0.2.6
60
+ */
61
+ Pathway.setMethod(function getValue() {
62
+
63
+ let child = this.querySelector('.al-pathway-selection-root');
64
+
65
+ if (child) {
66
+ return child.getValue();
67
+ }
68
+ });
69
+
70
+ /**
71
+ * Incoming change
72
+ *
73
+ * @author Jelle De Loecker <jelle@elevenways.be>
74
+ * @since 0.2.6
75
+ * @version 0.2.6
76
+ *
77
+ * @param {PathwaySelection} element
78
+ */
79
+ Pathway.setMethod(function triggerChange(element) {
80
+
81
+ alchemy.emit('story_pathway', this, element);
82
+ });