matestack-ui-vuejs 3.0.0.rc1 → 3.0.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c794def649692d36847b14964ae62336f5caef8b6176c54dca0527933f699ef1
4
- data.tar.gz: 6e588a4b84523a77133927ea8dd139e21cd8cb4f32fdff7a426613d50cd4d5ef
3
+ metadata.gz: b8903c4a0b4e9f78dab449dbba0ba30d58a4e5972eda54c994d984db17c92e48
4
+ data.tar.gz: 4be958ee0af7ca08fd299b45602a7cb1fdc5658a08aa3e143fbcdcbd6de953aa
5
5
  SHA512:
6
- metadata.gz: fb1e2b903e3a37fe6d99608496d44bf946716ea6562bea64a9a61fd6867b8fe2b380e5732c44a37675d51004bb6f01f4e071a1ea4e410a6750f003b825683d20
7
- data.tar.gz: 3a0a48ed03ffbb7241acda5908be725f827d859fa0ff83fc886df7841b9cddb35df4aa4521a6d49ef72bec080b415ba27e3f520b2096fb27ca6fab17c84a18b8
6
+ metadata.gz: da56aa8dfd8a8bdbd14470aae5f1d41b543fde8b047d18980d989b681267ad635fe1a078d65cde80c9fac4f0db700c086b811dfee7077fc5b76d8eff6295f65e
7
+ data.tar.gz: 36e841b06b328ef539bb8d54c29baa8d7b0f8b9845e836e12e155240e253e7eb0f40a11a075e72a6dd2195cfe9b6cd0d7659a0379adf5012ec124ca656608d94
data/README.md CHANGED
@@ -10,6 +10,8 @@
10
10
 
11
11
  Boost your productivity & easily create reactive web UIs in pure Ruby. Easily extend with pure JavaScript if required. No Opal involved.
12
12
 
13
+ **New repo, old git history? This repo was duplicated from `matestack-ui-core` in order to extract Vue.js features into `matestack-ui-vuejs` in Feburary 2022**
14
+
13
15
  ## About
14
16
 
15
17
  `matestack-ui-vuejs` ships all you need to build **reactive** UIs in **pure Ruby** orchestrating prebuilt Vue.js components with a simple Ruby DSL.
@@ -12,7 +12,7 @@ module Matestack
12
12
  end
13
13
 
14
14
  def component_attributes
15
- super.merge("matestack-ui-core-ref": "#{form_context.component_uid}-#{component_id}")
15
+ super.merge("matestack-ui-vuejs-ref": "#{form_context.component_uid}-#{component_id}")
16
16
  end
17
17
 
18
18
  def component_id
@@ -45,7 +45,11 @@ module Matestack
45
45
  if ctx.id.present?
46
46
  "'#{ctx.id}'"
47
47
  else
48
- "'#{key}'+vc.parentNestedFormRuntimeId"
48
+ if form_context.is_nested_form?
49
+ "'#{key}'+vc.parentNestedFormRuntimeId"
50
+ else
51
+ "'#{key}'"
52
+ end
49
53
  end
50
54
  end
51
55
 
@@ -61,7 +65,7 @@ module Matestack
61
65
 
62
66
  def attributes
63
67
  (options || {}).merge({
64
- "matestack-ui-core-ref": scoped_ref("input.#{attribute_key}"),
68
+ "matestack-ui-vuejs-ref": matestack_ui_vuejs_ref("input.#{attribute_key}"),
65
69
  ":id": id,
66
70
  type: ctx.type,
67
71
  multiple: ctx.multiple,
@@ -47,7 +47,7 @@ module Matestack
47
47
  type: :checkbox,
48
48
  name: item_label(item),
49
49
  "#{value_key(item)}": item_value(item),
50
- "matestack-ui-core-ref": scoped_ref("select.multiple.#{key}"),
50
+ "matestack-ui-vuejs-ref": matestack_ui_vuejs_ref("select.multiple.#{key}"),
51
51
  'v-on:change': change_event,
52
52
  'init-value': (init_value || []).to_json,
53
53
  'v-bind:class': "{ '#{error_class}': #{error_key} }",
@@ -14,12 +14,20 @@ const componentDef = {
14
14
  ],
15
15
  methods: {
16
16
  addItem: function(key){
17
- var templateString = JSON.parse(this.getElement().querySelector('#prototype-template-for-'+key).dataset[":template"])
18
- var tmp_dom_elem = document.createElement('div')
19
- tmp_dom_elem.innerHTML = templateString
20
- var static_prototype_template_uid = tmp_dom_elem.querySelector('matestack-component-template').id.replace("uid-", "")
21
- var dynamic_prototype_template_uid = Math.floor(Math.random() * 1000000000);
22
- var templateString = templateString.replaceAll(static_prototype_template_uid, dynamic_prototype_template_uid);
17
+ var templateString = JSON.parse(this.getTemplateElement().querySelector('#prototype-template-for-'+key).dataset[":template"])
18
+ var regex = /"component_uid":"(.+?)"/g
19
+ var staticComponentUidMatches = templateString.matchAll(regex)
20
+ var staticComponentUids = []
21
+ for (const match of staticComponentUidMatches) {
22
+ staticComponentUids.push(match[1])
23
+ }
24
+ staticComponentUids.forEach(function(uid){
25
+ var newUid = Math.floor(Math.random() * 1000000000);
26
+ templateString = templateString.replaceAll(uid, newUid);
27
+ })
28
+ var tmpDomElem = document.createElement('div')
29
+ tmpDomElem.innerHTML = templateString
30
+
23
31
  if (this.parentNestedFormRuntimeTemplateDomElements[key] == null){
24
32
  var dom_elem = document.createElement('div')
25
33
  dom_elem.innerHTML = templateString
@@ -25,7 +25,7 @@ module Matestack
25
25
  def attributes
26
26
  {
27
27
  class: 'matestack-form',
28
- "matestack-ui-core-ref": scoped_ref('form'),
28
+ "matestack-ui-vuejs-ref": matestack_ui_vuejs_ref('form'),
29
29
  'v-bind:class': "{ 'has-errors': vc.hasErrors(), loading: vc.loading }",
30
30
  'v-on:submit.prevent': 'vc.perform',
31
31
  }
@@ -106,13 +106,13 @@ const componentDef = {
106
106
  this.parentDeletedNestedForms[this.props["fields_for"]] = [];
107
107
  }
108
108
 
109
- var id = parseInt(self.getElement().querySelector('.matestack-form-fields-for').id.replace(this.props["fields_for"]+"_child_", ""))
109
+ var id = parseInt(self.getTemplateElement().querySelector('.matestack-form-fields-for').id.replace(this.props["fields_for"]+"_child_", ""))
110
110
 
111
111
  //setup data binding for serverside rendered nested forms
112
112
  if (isNaN(id)){
113
113
  id = this.parentNestedForms[this.props["fields_for"]].length
114
114
  this.nestedFormRuntimeId = "_"+this.props["fields_for"]+"_child_"+id
115
- this.getElement().id = this.props["fields_for"]+"_child_"+id
115
+ this.getTemplateElement().id = this.props["fields_for"]+"_child_"+id
116
116
  this.initValues()
117
117
  this.parentFormData[this.props["fields_for"]].push(this.data);
118
118
  this.parentNestedForms[this.props["fields_for"]].push(this);
@@ -36,7 +36,7 @@ module Matestack
36
36
  ":id": item_id(item),
37
37
  name: item_name(item),
38
38
  type: :radio,
39
- "matestack-ui-core-ref": scoped_ref("select.#{key}"),
39
+ "matestack-ui-vuejs-ref": matestack_ui_vuejs_ref("select.#{key}"),
40
40
  'value-type': value_type(item_value(radio_options.first))
41
41
  }).tap do |attrs|
42
42
  attrs[value_key(item)] = item_value(item)
@@ -44,7 +44,7 @@ module Matestack
44
44
  attributes.except(:options).merge({
45
45
  multiple: multiple,
46
46
  ":id": id,
47
- "matestack-ui-core-ref": scoped_ref("select#{'.multiple' if multiple}.#{key}"),
47
+ "matestack-ui-vuejs-ref": matestack_ui_vuejs_ref("select#{'.multiple' if multiple}.#{key}"),
48
48
  'value-type': value_type(select_options.first),
49
49
  'init-value': init_value,
50
50
  })
@@ -1,7 +1,7 @@
1
1
  import matestackEventHub from '../event_hub'
2
2
 
3
3
  const componentMixin = {
4
- props: ['props', 'params', 'matestack-ui-core-ref'],
4
+ props: ['props', 'params', 'matestack-ui-vuejs-ref'],
5
5
  computed: {
6
6
  vc: function(){
7
7
  return this;
@@ -15,13 +15,13 @@ const componentMixin = {
15
15
  // that's the reason for the following workaround
16
16
  var componentScopedRefs = {};
17
17
  var scopeId = this.props['component_uid'];
18
- var componentRelativeRefs = this.getElement().querySelectorAll("[matestack-ui-core-ref]")
18
+ var componentRelativeRefs = this.getTemplateElement().querySelectorAll("[matestack-ui-vuejs-ref]")
19
19
  // var defaultSlot = this.$slots.default({ vc: this.vc })[0]
20
20
  // var globalRefs = defaultSlot.context.$refs
21
21
  for (let i in componentRelativeRefs) {
22
22
  let node = componentRelativeRefs[i]
23
23
  if (node.getAttribute){
24
- let nodeRef = node.getAttribute("matestack-ui-core-ref")
24
+ let nodeRef = node.getAttribute("matestack-ui-vuejs-ref")
25
25
  if(nodeRef.startsWith(scopeId)){
26
26
  componentScopedRefs[nodeRef.replace(scopeId+"-", "")] = node
27
27
  }
@@ -30,9 +30,12 @@ const componentMixin = {
30
30
  }
31
31
  return componentScopedRefs;
32
32
  },
33
- getElement: function(){
33
+ getTemplateElement: function(){
34
34
  return document.getElementById("uid-"+this.props['component_uid']);
35
35
  },
36
+ getElement: function(){
37
+ return this.getTemplateElement().firstChild;
38
+ },
36
39
  registerEvents: function(events, callback){
37
40
  if(events != undefined){
38
41
  var event_names = events.split(",")
@@ -1,7 +1,7 @@
1
1
  module Matestack
2
2
  module Ui
3
3
  module VueJs
4
- VERSION = '3.0.0.rc1'
4
+ VERSION = '3.0.0'
5
5
  end
6
6
  end
7
7
  end
@@ -18,7 +18,7 @@ module Matestack
18
18
 
19
19
  def vue_component(&block)
20
20
  Matestack::Ui::Core::Base.new(:component, component_attributes) do
21
- Matestack::Ui::Core::Base.new("matestack-component-template", 'id': "uid-#{component_uid}") do
21
+ Matestack::Ui::Core::Base.new("matestack-component-template", 'for': vue_name, 'id': "uid-#{component_uid}") do
22
22
  yield
23
23
  end
24
24
  end
@@ -51,7 +51,7 @@ module Matestack
51
51
  end
52
52
  alias :config :vue_props
53
53
 
54
- def scoped_ref(value)
54
+ def matestack_ui_vuejs_ref(value)
55
55
  return "#{component_uid}-#{value}" unless value.nil?
56
56
  end
57
57
 
@@ -11,7 +11,6 @@ end
11
11
 
12
12
  require "#{vue_js_base_path}/version"
13
13
 
14
- require "#{vue_js_base_path}/utils"
15
14
  require "#{vue_js_base_path}/vue_attributes"
16
15
  require "#{vue_js_base_path}/vue"
17
16
  require "#{vue_js_base_path}/components/app"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: matestack-ui-vuejs
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0.rc1
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonas Jabari
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-02-11 00:00:00.000000000 Z
11
+ date: 2022-03-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: matestack-ui-core
@@ -118,7 +118,6 @@ files:
118
118
  - lib/matestack/ui/vue_js/helpers/query_params_helper.js
119
119
  - lib/matestack/ui/vue_js/index.js
120
120
  - lib/matestack/ui/vue_js/initialize.rb
121
- - lib/matestack/ui/vue_js/utils.rb
122
121
  - lib/matestack/ui/vue_js/version.rb
123
122
  - lib/matestack/ui/vue_js/vue.rb
124
123
  - lib/matestack/ui/vue_js/vue_attributes.rb
@@ -139,9 +138,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
139
138
  version: '0'
140
139
  required_rubygems_version: !ruby/object:Gem::Requirement
141
140
  requirements:
142
- - - ">"
141
+ - - ">="
143
142
  - !ruby/object:Gem::Version
144
- version: 1.3.1
143
+ version: '0'
145
144
  requirements: []
146
145
  rubygems_version: 3.1.4
147
146
  signing_key:
@@ -1,67 +0,0 @@
1
- module Matestack
2
- module Ui
3
- module VueJs
4
- module Utils
5
-
6
- def self.included(base)
7
- base.extend(ClassMethods)
8
- end
9
- module ClassMethods
10
- def vue_name(name = nil)
11
- name ? @vue_name = name : @vue_name
12
- end
13
-
14
- def inherited(subclass)
15
- subclass.vue_name(self.vue_name)
16
- super
17
- end
18
- end
19
-
20
- def vue_component(&block)
21
- Matestack::Ui::Core::Base.new(:component, component_attributes) do
22
- Matestack::Ui::Core::Base.new("matestack-component-template", 'id': "uid-#{component_uid}") do
23
- yield
24
- end
25
- end
26
- end
27
-
28
- def component_attributes
29
- {
30
- is: vue_name,
31
- ref: component_id,
32
- ':params': params.to_json,
33
- ':props': base_vue_props.merge(vue_props)&.to_json,
34
- 'v-slot': "{ vc }"
35
- }
36
- end
37
-
38
- def component_id
39
- options[:id] || nil
40
- end
41
-
42
- def component_uid
43
- @component_uid ||= SecureRandom.hex
44
- end
45
-
46
- def base_vue_props
47
- { component_uid: component_uid }
48
- end
49
-
50
- def vue_props
51
- {} # can be overwritten in sub class
52
- end
53
- alias :config :vue_props
54
-
55
- def scoped_ref(value)
56
- return "#{component_uid}-#{value}" unless value.nil?
57
- end
58
-
59
- def vue_name
60
- raise "vue_name missing for #{self.class}" unless self.class.vue_name
61
- self.class.vue_name
62
- end
63
-
64
- end
65
- end
66
- end
67
- end