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
File without changes
@@ -854,7 +854,7 @@ AlchemySelect.setMethod(function _processPreloadedValues() {
854
854
  *
855
855
  * @author Jelle De Loecker <jelle@develry.be>
856
856
  * @since 0.1.0
857
- * @version 0.1.8
857
+ * @version 0.2.6
858
858
  *
859
859
  * @param {Object} response
860
860
  * @param {Number} page The page, if it's via pagination
@@ -872,7 +872,11 @@ AlchemySelect.setMethod(function _processResponseData(response, page) {
872
872
  let records = response.items || response.records;
873
873
 
874
874
  if (!records) {
875
- records = [];
875
+ if (Array.isArray(response)) {
876
+ records = response;
877
+ } else {
878
+ records = [];
879
+ }
876
880
  }
877
881
 
878
882
  this._processResponseList(records, page);
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -0,0 +1,174 @@
1
+ /**
2
+ * A Pathway tree
3
+ *
4
+ * @constructor
5
+ *
6
+ * @author Jelle De Loecker <jelle@elevenways.be>
7
+ * @since 0.2.6
8
+ * @version 0.2.6
9
+ *
10
+ * @param {Leaf} parent Optional parent leaf
11
+ */
12
+ const Leaf = Function.inherits('Alchemy.Base', 'Alchemy.Form.Pathway', function Leaf(id, parent) {
13
+
14
+ // The id of this leaf
15
+ this.id = id;
16
+
17
+ // The parent leaf
18
+ this.parent = parent;
19
+
20
+ // The children
21
+ this.children = [];
22
+
23
+ // The data provider
24
+ this._provider = null;
25
+ });
26
+
27
+ /**
28
+ * Undry
29
+ *
30
+ * @author Jelle De Loecker <jelle@elevenways.be>
31
+ * @since 0.2.6
32
+ * @version 0.2.6
33
+ *
34
+ * @param {Object} obj
35
+ * @param {Boolean|String} cloned
36
+ *
37
+ * @return {Leaf}
38
+ */
39
+ Leaf.setStatic(function unDry(obj) {
40
+
41
+ let result = new this(obj.id);
42
+
43
+ if (obj.children) {
44
+ for (let child of obj.children) {
45
+ child.parent = result;
46
+ }
47
+
48
+ result.children = obj.children;
49
+ }
50
+
51
+ result._provider = obj.provider;
52
+
53
+ return result;
54
+ });
55
+
56
+ /**
57
+ * Get the displaytitle of this leaf
58
+ *
59
+ * @author Jelle De Loecker <jelle@elevenways.be>
60
+ * @since 0.2.6
61
+ * @version 0.2.6
62
+ *
63
+ * @return {Microcopy}
64
+ */
65
+ Leaf.setMethod(function getDisplayTitle() {
66
+
67
+ let key = 'pathway-leaf-title',
68
+ params = {leaf_id: this.id};
69
+
70
+ return new Classes.Alchemy.Microcopy(key, params);
71
+ });
72
+
73
+ /**
74
+ * Add a new child
75
+ *
76
+ * @author Jelle De Loecker <jelle@elevenways.be>
77
+ * @since 0.2.6
78
+ * @version 0.2.6
79
+ *
80
+ * @return {Leaf}
81
+ */
82
+ Leaf.setMethod(function addChild(id) {
83
+
84
+ let leaf = new Leaf(id, this);
85
+
86
+ this.children.push(leaf);
87
+
88
+ return leaf;
89
+ });
90
+
91
+ /**
92
+ * Set the data provider
93
+ *
94
+ * @author Jelle De Loecker <jelle@elevenways.be>
95
+ * @since 0.2.6
96
+ * @version 0.2.6
97
+ */
98
+ Leaf.setMethod(function setProvider(provider) {
99
+ this._provider = provider;
100
+ });
101
+
102
+ /**
103
+ * Get the data provider
104
+ *
105
+ * @author Jelle De Loecker <jelle@elevenways.be>
106
+ * @since 0.2.6
107
+ * @version 0.2.6
108
+ *
109
+ * @return {DataProvider}
110
+ */
111
+ Leaf.setMethod(function getProvider() {
112
+
113
+ if (typeof this._provider == 'string') {
114
+ let provider = new Classes.Alchemy.DataProvider.Remote();
115
+ provider.source = alchemy.routeUrl(this._provider);
116
+
117
+ provider.context = {
118
+ leaf_id : this.id
119
+ };
120
+
121
+ return provider;
122
+ }
123
+
124
+ });
125
+
126
+
127
+ /**
128
+ * Get the given page
129
+ *
130
+ * @author Jelle De Loecker <jelle@elevenways.be>
131
+ * @since 0.2.6
132
+ * @version 0.2.6
133
+ *
134
+ * @return {DataProvider}
135
+ */
136
+ Leaf.setMethod(async function getPage(page_nr) {
137
+
138
+ let provider = this.getProvider();
139
+
140
+ console.log('Getting page...', page_nr, 'from', provider)
141
+
142
+ if (!provider) {
143
+ return;
144
+ }
145
+
146
+ let records = await provider.getAll();
147
+
148
+ console.log('Got records:', records)
149
+
150
+ return records;
151
+
152
+ });
153
+
154
+ /**
155
+ * Return an object for json-drying this document
156
+ *
157
+ * @author Jelle De Loecker <jelle@elevenways.be>
158
+ * @since 0.2.6
159
+ * @version 0.2.6
160
+ *
161
+ * @return {Object}
162
+ */
163
+ Leaf.setMethod(function toDry() {
164
+
165
+ let result = {
166
+ value : {
167
+ id : this.id,
168
+ provider : this._provider,
169
+ children : this.children,
170
+ }
171
+ };
172
+
173
+ return result;
174
+ });
File without changes
File without changes
File without changes
File without changes
File without changes
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "alchemy-form",
3
3
  "description": "Form plugin for Alchemy",
4
- "version": "0.2.5",
4
+ "version": "0.2.7",
5
5
  "repository": {
6
6
  "type" : "git",
7
7
  "url" : "https://github.com/11ways/alchemy-form.git"
8
8
  },
9
9
  "peerDependencies": {
10
- "alchemymvc" : ">=1.2.0",
11
- "alchemy-media" : ">=0.7.2"
10
+ "alchemymvc" : ">=1.3.0",
11
+ "alchemy-media" : ">=0.7.6"
12
12
  },
13
13
  "license": "MIT",
14
14
  "engines": {
@@ -0,0 +1,5 @@
1
+ <al-pathway-selection
2
+ class="al-pathway-selection-root"
3
+ #selected_leaf={% self.rootleaf %}
4
+ #value={% self.value %}
5
+ ></al-pathway-selection>
@@ -0,0 +1,10 @@
1
+ <div class="leaf-info">
2
+ <span class="select-button">
3
+ <span class="select-button-title">
4
+ {{ self.getDisplayTitle() }}
5
+ </span>
6
+ </span>
7
+ </div>
8
+ <div class="leaf-children">
9
+ <% self.populateChildren($0) %>
10
+ </div>
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -1,3 +1,5 @@
1
+ <% self.classList.add('does-not-expand') %>
2
+
1
3
  <input
2
4
  type="checkbox"
3
5
  <% if (self.value) print('checked') %>
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -4,6 +4,8 @@
4
4
  {% set type = "text" %}
5
5
  {% /if %}
6
6
 
7
+ <% if (type == 'string') type = 'text'; %>
8
+
7
9
  <input
8
10
  value=<% value %>
9
11
  class="alchemy-field-value"
@@ -2,4 +2,4 @@
2
2
  class="alchemy-field-value"
3
3
  form=<% form_id %>
4
4
  name=<% path %>
5
- >{%= value.encodeHTML() %}</textarea>
5
+ >{{ value }}</textarea>
File without changes
File without changes
File without changes
File without changes
@@ -1,4 +1 @@
1
- <time
2
- class="alchemy-field-value"
3
- datetime={% value.toISOString() %}
4
- >{{ value.format('Y‑m‑d') }}</time>
1
+ <% include('form/inputs/view_inline/datetime') %>
@@ -1,8 +1,28 @@
1
- {% if alchemy_field.config.options.time_ago %}
2
- <time-ago date={% value %}></time-ago>
3
- {% else %}
1
+ <%
2
+ date_format = '';
3
+
4
+ if (alchemy_field && alchemy_field.applied_options) {
5
+ date_format = alchemy_field.applied_options.date_format;
6
+ }
7
+
8
+ if (!date_format || date_format == 'timeago' || date_format == 'time-ago' || date_format == 'time_ago') {
9
+ date_format = 'relative';
10
+ }
11
+
12
+ if (alchemy_field?.config?.options?.time_ago) {
13
+ date_format = 'relative';
14
+ }
15
+
16
+ %>
17
+
18
+ <% if (date_format == 'relative') { %>
19
+ <time-ago
20
+ class="alchemy-field-value"
21
+ date={% value.toISOString() %}
22
+ ></time-ago>
23
+ <% } else { %>
4
24
  <time
5
25
  class="alchemy-field-value"
6
26
  datetime={% value.toISOString() %}
7
- >{{ value.format('Y‑m‑d H:i') }}</time>
8
- {% /if %}
27
+ >{{ value.format(date_format) }}</time>
28
+ <% } %>
File without changes
File without changes
File without changes
File without changes
@@ -3,11 +3,11 @@
3
3
  <span
4
4
  data-he-name="field-title"
5
5
  data-he-slot="field-title"
6
- ><%= alchemy_field.field_title %></span>
6
+ >{{ alchemy_field.field_title }}</span>
7
7
  <small
8
8
  data-he-name="field-description"
9
9
  data-he-slot="field-description"
10
- ><%= alchemy_field.field_description %></small>
10
+ >{{ alchemy_field.field_description }}</small>
11
11
  </al-label>
12
12
  </div>
13
13
  <div data-he-name="field"></div>
File without changes
File without changes