vue_crud 0.1.0 → 0.1.1

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
  SHA1:
3
- metadata.gz: 7a3968959d978911425d23ccc57bad7a6e520b1d
4
- data.tar.gz: e22d398e429375cb72eb45068d691f8e8db1201d
3
+ metadata.gz: 506d7ad9c2466b813f95735b7f9c10c7eeffe02e
4
+ data.tar.gz: 66e86d9227f5fdef4418616b03c1d8ea56ae1cff
5
5
  SHA512:
6
- metadata.gz: 68fcb6ff3f771628a6d82db744af6e76d87b9e143dea98ab6736a9412d0cd59a82ecc938279c0098fe1e73d6bf43dffea411d7dba191dc6f6e2f0ca1fe478fe2
7
- data.tar.gz: b57aad62dbf33091b101f4128cabb298a8e73952fa28570a9b7504dbe174c8cd67cd6a19b7020b28d4104ca0cea5a9ce1a5934d6c32f0f6a08e9975a39e3868a
6
+ metadata.gz: 5b9864cab21691306ea0bf3e632181a856f0fd0ab6707a996f2f25d7a24d5f48c267c6ed71222ad3de355ac66ddfb955aa59e71980878c1be1d6c578f95d3295
7
+ data.tar.gz: c73a836eeded14260e4315d260f769256c76dcc9b423648d930d9355a4fdaf1e01479b6985fafa5b811f1baeaa30010bfefd7fe9b25fd3b4779ce99e1c3901ec
@@ -1,4 +1,3 @@
1
- #lib/generators/gemname/install_generator.rb
2
1
  require 'rails/generators'
3
2
  module VueCrud
4
3
  class InstallGenerator < Rails::Generators::Base
@@ -1,31 +1,35 @@
1
1
  <script type="text/javascript">
2
2
  $(document).ready(function() {
3
+ var column_type = 'card';
3
4
  $('.vue_form_for_new').html($('#vue_form').html());
4
- var model_row = $($('#model-row').html());
5
- model_row.find('.custom_model_row').html(
6
- $('#custom_model_row').html()
5
+ var models = $($('#models-' + column_type).html());
6
+ models.find('.custom_models').html(
7
+ $('#custom_models').html()
7
8
  );
8
- model_row.find('.custom_action').html(
9
+ models.find('.custom_action').html(
9
10
  $('#custom_action').html()
10
11
  );
11
- model_row.find('.vue_form_for_edit').html(
12
+ models.find('.vue_form_for_edit').html(
12
13
  $('#vue_form').html()
13
14
  );
14
- model_row.find('.custom_modal_body').html(
15
+ models.find('.custom_modal_body').html(
15
16
  $('#custom_modal_body').html()
16
17
  );
17
- model_row.find('.custom_modal_action').html(
18
+ models.find('.custom_modal_action').html(
18
19
  $('#custom_modal_action').html()
19
20
  );
20
21
 
21
- $('#model-row').html(model_row);
22
- vue_init();
22
+ $('#models-' + column_type).html(models);
23
+ vue_init({
24
+ column_type: column_type,
25
+ suffix: '.json'
26
+ });
23
27
  $('.filter .ui.dropdown').dropdown();
24
28
  });
25
29
  </script>
26
30
 
27
31
 
28
- <div id="models">
32
+ <div id="vue_crud">
29
33
  <input type="text" name="progress" id="form-progress">
30
34
  <h1 class="ui header">
31
35
  {{ info.titles.title }}
@@ -48,7 +52,7 @@ $(document).ready(function() {
48
52
  </div>
49
53
  <div class="ui divider"></div>
50
54
  <!-- NOTE: Pagination -->
51
- <div class="ui pagination menu">
55
+ <div class="ui pagination menu" v-if="column_type == 'card'">
52
56
  <a class="item" @click.prevent="setPage(currentPage-1)" :class="{'disabled': (currentPage == '1')}">
53
57
 
54
58
  </a>
@@ -59,12 +63,43 @@ $(document).ready(function() {
59
63
 
60
64
  </a>
61
65
  </div>
62
- <div class="ui divider"></div>
63
- <!-- NOTE: model-row -->
64
- <div class="row ui cards">
65
- <model-row is="model-row" v-for="model in filteredModels" :model="model" :info="info" :selected_attribute="model_prefix + '.' + selected_attribute"></model-row>
66
+ <div class="ui divider" v-if="column_type == 'card'"></div>
67
+ <!-- NOTE: models -->
68
+ <div class="row ui cards" v-if="column_type == 'card'">
69
+ <models v-for="model in filteredModels" :model="model" :info="info" :selected_attribute="model_prefix + '.' + selected_attribute"></models>
66
70
  </div>
67
71
 
72
+ <table class="ui celled table" v-if="column_type == 'table'">
73
+ <thead>
74
+ <tr>
75
+ <th v-for="attribute in info.model_attributes" v-if="attribute.visible" :class="{highlight: attribute.model_prefix + '.' + attribute.name == model_prefix + '.' + selected_attribute}">
76
+ {{ attribute.display_name }}
77
+ </th>
78
+ </tr>
79
+ </thead>
80
+ <tbody>
81
+ <tr is="models" v-for="model in filteredModels" :model="model" :info="info" :selected_attribute="model_prefix + '.' + selected_attribute">
82
+ </tr>
83
+ </tbody>
84
+ <tfoot>
85
+ <tr>
86
+ <th :colspan="info.model_attributes.length">
87
+ <div class="ui right floated pagination menu">
88
+ <a class="item" @click.prevent="setPage(currentPage-1)" :class="{'disabled': (currentPage == '1')}">
89
+
90
+ </a>
91
+ <a v-for="n in totalPage" @click.prevent="setPage(n)" :class="{'active': (currentPage == (n))}" class="item">
92
+ {{n}}
93
+ </a>
94
+ <a class="item" @click.prevent="setPage(currentPage+1)" :class="{'disabled': (currentPage == totalPage)}">
95
+
96
+ </a>
97
+ </div>
98
+ </th>
99
+ </tr>
100
+ </tfoot>
101
+ </table>
102
+
68
103
  <!-- NOTE: modal for new action -->
69
104
  <div class="ui modal new_modal" id="modelModal">
70
105
  <div class="header">Create {{ info.titles.title }}</div>
@@ -81,7 +116,22 @@ $(document).ready(function() {
81
116
  </div>
82
117
 
83
118
  <!-- NOTE: Templates -->
84
- <script type="text/x-template" id="model-row">
119
+ <script type="text/x-template" id="models-table">
120
+ <tr>
121
+ <!-- <td>
122
+ <div class="ui ribbon label">First</div>
123
+ </td> -->
124
+ <td v-for="attribute in info.model_attributes" v-if="attribute.visible" :class="{highlight: attribute.model_prefix + '.' + attribute.name == selected_attribute}">
125
+ <p v-if="attribute.model_prefix">
126
+ {{ model[attribute.model_prefix][attribute.name] }}
127
+ </p>
128
+ <p v-else>
129
+ {{ model[attribute.name] }}
130
+ </p>
131
+ </td>
132
+ </tr>
133
+ </script>
134
+ <script type="text/x-template" id="models-card">
85
135
  <div class="col-md-4">
86
136
  <div class="card">
87
137
  <div class="content">
@@ -102,8 +152,8 @@ $(document).ready(function() {
102
152
  </div>
103
153
  </div>
104
154
  </div>
105
- <!-- NOTE: Custom model row -->
106
- <div class="custom_model_row"></div>
155
+ <!-- NOTE: Custom models -->
156
+ <div class="custom_models"></div>
107
157
  </div>
108
158
  </div>
109
159
  <div class="extra content">
@@ -209,13 +259,13 @@ $(document).ready(function() {
209
259
  </script>
210
260
  <!-- NOTE: memo-->
211
261
  <!-- <div class="row well well-sm">
212
- <model-row is="model-row" v-for="model in models" :model="model"></model-row>
262
+ <models v-for="model in models" :model="model"></models>
213
263
  </div> -->
214
264
  <!-- ┌───────────────────────────────────────┐ -->
215
265
  <!-- │ ↓ -->
216
266
  <!-- v-for model in models 這個 model 會透過 :model="model" 傳值到 template,無法直接使用 v-for 迴圈出來的 model -->
217
267
  <!-- │
218
- In model-row component props: { ↓
268
+ In models component props: { ↓
219
269
  model: Object
220
270
  }
221
271
  -->
@@ -1,3 +1,3 @@
1
1
  module VueCrud
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -1,5 +1,6 @@
1
+ (function(){var t,e,n,r,s,o,i,u,a,c,l,p,h,g,f,d,m,y,v,w,b,k,S,q,L,x,T,R,P,E,j,M,A,N,O,_,F,C,U,W,X,I,D,H,z,B,G,J,Q,K=[].slice,V={}.hasOwnProperty,Y=function(t,e){function n(){this.constructor=t}for(var r in e)V.call(e,r)&&(t[r]=e[r]);return n.prototype=e.prototype,t.prototype=new n,t.__super__=e.prototype,t},Z=[].indexOf||function(t){for(var e=0,n=this.length;n>e;e++)if(e in this&&this[e]===t)return e;return-1};for(b={catchupTime:100,initialRate:.03,minTime:250,ghostTime:100,maxProgressPerFrame:20,easeFactor:1.25,startOnPageLoad:!0,restartOnPushState:!0,restartOnRequestAfter:500,target:"body",elements:{checkInterval:100,selectors:["body"]},eventLag:{minSamples:10,sampleCount:3,lagThreshold:3},ajax:{trackMethods:["GET"],trackWebSockets:!0,ignoreURLs:[]}},P=function(){var t;return null!=(t="undefined"!=typeof performance&&null!==performance&&"function"==typeof performance.now?performance.now():void 0)?t:+new Date},j=window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||window.msRequestAnimationFrame,w=window.cancelAnimationFrame||window.mozCancelAnimationFrame,null==j&&(j=function(t){return setTimeout(t,50)},w=function(t){return clearTimeout(t)}),A=function(t){var e,n;return e=P(),(n=function(){var r;return r=P()-e,r>=33?(e=P(),t(r,function(){return j(n)})):setTimeout(n,33-r)})()},M=function(){var t,e,n;return n=arguments[0],e=arguments[1],t=3<=arguments.length?K.call(arguments,2):[],"function"==typeof n[e]?n[e].apply(n,t):n[e]},k=function(){var t,e,n,r,s,o,i;for(e=arguments[0],r=2<=arguments.length?K.call(arguments,1):[],o=0,i=r.length;i>o;o++)if(n=r[o])for(t in n)V.call(n,t)&&(s=n[t],null!=e[t]&&"object"==typeof e[t]&&null!=s&&"object"==typeof s?k(e[t],s):e[t]=s);return e},m=function(t){var e,n,r,s,o;for(n=e=0,s=0,o=t.length;o>s;s++)r=t[s],n+=Math.abs(r),e++;return n/e},q=function(t,e){var n,r,s;if(null==t&&(t="options"),null==e&&(e=!0),s=document.querySelector("[data-pace-"+t+"]")){if(n=s.getAttribute("data-pace-"+t),!e)return n;try{return JSON.parse(n)}catch(o){return r=o,"undefined"!=typeof console&&null!==console?console.error("Error parsing inline pace options",r):void 0}}},i=function(){function t(){}return t.prototype.on=function(t,e,n,r){var s;return null==r&&(r=!1),null==this.bindings&&(this.bindings={}),null==(s=this.bindings)[t]&&(s[t]=[]),this.bindings[t].push({handler:e,ctx:n,once:r})},t.prototype.once=function(t,e,n){return this.on(t,e,n,!0)},t.prototype.off=function(t,e){var n,r,s;if(null!=(null!=(r=this.bindings)?r[t]:void 0)){if(null==e)return delete this.bindings[t];for(n=0,s=[];n<this.bindings[t].length;)s.push(this.bindings[t][n].handler===e?this.bindings[t].splice(n,1):n++);return s}},t.prototype.trigger=function(){var t,e,n,r,s,o,i,u,a;if(n=arguments[0],t=2<=arguments.length?K.call(arguments,1):[],null!=(i=this.bindings)?i[n]:void 0){for(s=0,a=[];s<this.bindings[n].length;)u=this.bindings[n][s],r=u.handler,e=u.ctx,o=u.once,r.apply(null!=e?e:this,t),a.push(o?this.bindings[n].splice(s,1):s++);return a}},t}(),c=window.Pace||{},window.Pace=c,k(c,i.prototype),E=c.options=k({},b,window.paceOptions,q()),G=["ajax","document","eventLag","elements"],D=0,z=G.length;z>D;D++)F=G[D],E[F]===!0&&(E[F]=b[F]);a=function(t){function e(){return J=e.__super__.constructor.apply(this,arguments)}return Y(e,t),e}(Error),e=function(){function t(){this.progress=0}return t.prototype.getElement=function(){var t;if(null==this.el){if(t=document.querySelector(E.target),!t)throw new a;this.el=document.createElement("div"),this.el.className="pace pace-active",document.body.className=document.body.className.replace(/pace-done/g,""),document.body.className+=" pace-running",this.el.innerHTML='<div class="pace-progress">\n <div class="pace-progress-inner"></div>\n</div>\n<div class="pace-activity"></div>',null!=t.firstChild?t.insertBefore(this.el,t.firstChild):t.appendChild(this.el)}return this.el},t.prototype.finish=function(){var t;return t=this.getElement(),t.className=t.className.replace("pace-active",""),t.className+=" pace-inactive",document.body.className=document.body.className.replace("pace-running",""),document.body.className+=" pace-done"},t.prototype.update=function(t){return this.progress=t,this.render()},t.prototype.destroy=function(){try{this.getElement().parentNode.removeChild(this.getElement())}catch(t){a=t}return this.el=void 0},t.prototype.render=function(){var t,e,n,r,s,o,i;if(null==document.querySelector(E.target))return!1;for(t=this.getElement(),r="translate3d("+this.progress+"%, 0, 0)",i=["webkitTransform","msTransform","transform"],s=0,o=i.length;o>s;s++)e=i[s],t.children[0].style[e]=r;var u=document.getElementById("form-progress");return"undefined"!=typeof u&&null!=u&&(u.value=0|this.progress,jQuery(u).change()),(!this.lastRenderedProgress||this.lastRenderedProgress|0!==this.progress|0)&&(t.children[0].setAttribute("data-progress-text",""+(0|this.progress)+"%"),this.progress>=100?n="99":(n=this.progress<10?"0":"",n+=0|this.progress),t.children[0].setAttribute("data-progress",""+n)),this.lastRenderedProgress=this.progress},t.prototype.done=function(){return this.progress>=100},t}(),u=function(){function t(){this.bindings={}}return t.prototype.trigger=function(t,e){var n,r,s,o,i;if(null!=this.bindings[t]){for(o=this.bindings[t],i=[],r=0,s=o.length;s>r;r++)n=o[r],i.push(n.call(this,e));return i}},t.prototype.on=function(t,e){var n;return null==(n=this.bindings)[t]&&(n[t]=[]),this.bindings[t].push(e)},t}(),I=window.XMLHttpRequest,X=window.XDomainRequest,W=window.WebSocket,S=function(t,e){var n,r,s,o;o=[];for(r in e.prototype)try{s=e.prototype[r],o.push(null==t[r]&&"function"!=typeof s?t[r]=s:void 0)}catch(i){n=i}return o},T=[],c.ignore=function(){var t,e,n;return e=arguments[0],t=2<=arguments.length?K.call(arguments,1):[],T.unshift("ignore"),n=e.apply(null,t),T.shift(),n},c.track=function(){var t,e,n;return e=arguments[0],t=2<=arguments.length?K.call(arguments,1):[],T.unshift("track"),n=e.apply(null,t),T.shift(),n},_=function(t){var e;if(null==t&&(t="GET"),"track"===T[0])return"force";if(!T.length&&E.ajax){if("socket"===t&&E.ajax.trackWebSockets)return!0;if(e=t.toUpperCase(),Z.call(E.ajax.trackMethods,e)>=0)return!0}return!1},l=function(t){function e(){var t,n=this;e.__super__.constructor.apply(this,arguments),t=function(t){var e;return e=t.open,t.open=function(r,s){return _(r)&&n.trigger("request",{type:r,url:s,request:t}),e.apply(t,arguments)}},window.XMLHttpRequest=function(e){var n;return n=new I(e),t(n),n};try{S(window.XMLHttpRequest,I)}catch(r){}if(null!=X){window.XDomainRequest=function(){var e;return e=new X,t(e),e};try{S(window.XDomainRequest,X)}catch(r){}}if(null!=W&&E.ajax.trackWebSockets){window.WebSocket=function(t,e){var r;return r=null!=e?new W(t,e):new W(t),_("socket")&&n.trigger("request",{type:"socket",url:t,protocols:e,request:r}),r};try{S(window.WebSocket,W)}catch(r){}}}return Y(e,t),e}(u),H=null,L=function(){return null==H&&(H=new l),H},O=function(t){var e,n,r,s;for(s=E.ajax.ignoreURLs,n=0,r=s.length;r>n;n++)if(e=s[n],"string"==typeof e){if(-1!==t.indexOf(e))return!0}else if(e.test(t))return!0;return!1},L().on("request",function(e){var n,r,s,o,i;return o=e.type,s=e.request,i=e.url,O(i)?void 0:c.running||E.restartOnRequestAfter===!1&&"force"!==_(o)?void 0:(r=arguments,n=E.restartOnRequestAfter||0,"boolean"==typeof n&&(n=0),setTimeout(function(){var e,n,i,u,a,l;if(e="socket"===o?s.readyState<2:0<(u=s.readyState)&&4>u){for(c.restart(),a=c.sources,l=[],n=0,i=a.length;i>n;n++){if(F=a[n],F instanceof t){F.watch.apply(F,r);break}l.push(void 0)}return l}},n))}),t=function(){function t(){var t=this;this.elements=[],L().on("request",function(){return t.watch.apply(t,arguments)})}return t.prototype.watch=function(t){var e,n,r,s;return r=t.type,e=t.request,s=t.url,O(s)?void 0:(n="socket"===r?new g(e):new f(e),this.elements.push(n))},t}(),f=function(){function t(t){var e,n,r,s,o,i,u=this;if(this.progress=0,null!=window.ProgressEvent)for(n=null,t.addEventListener("progress",function(t){return u.progress=t.lengthComputable?100*t.loaded/t.total:u.progress+(100-u.progress)/2},!1),i=["load","abort","timeout","error"],r=0,s=i.length;s>r;r++)e=i[r],t.addEventListener(e,function(){return u.progress=100},!1);else o=t.onreadystatechange,t.onreadystatechange=function(){var e;return 0===(e=t.readyState)||4===e?u.progress=100:3===t.readyState&&(u.progress=50),"function"==typeof o?o.apply(null,arguments):void 0}}return t}(),g=function(){function t(t){var e,n,r,s,o=this;for(this.progress=0,s=["error","open"],n=0,r=s.length;r>n;n++)e=s[n],t.addEventListener(e,function(){return o.progress=100},!1)}return t}(),r=function(){function t(t){var e,n,r,o;for(null==t&&(t={}),this.elements=[],null==t.selectors&&(t.selectors=[]),o=t.selectors,n=0,r=o.length;r>n;n++)e=o[n],this.elements.push(new s(e))}return t}(),s=function(){function t(t){this.selector=t,this.progress=0,this.check()}return t.prototype.check=function(){var t=this;return document.querySelector(this.selector)?this.done():setTimeout(function(){return t.check()},E.elements.checkInterval)},t.prototype.done=function(){return this.progress=100},t}(),n=function(){function t(){var t,e,n=this;this.progress=null!=(e=this.states[document.readyState])?e:100,t=document.onreadystatechange,document.onreadystatechange=function(){return null!=n.states[document.readyState]&&(n.progress=n.states[document.readyState]),"function"==typeof t?t.apply(null,arguments):void 0}}return t.prototype.states={loading:0,interactive:50,complete:100},t}(),o=function(){function t(){var t,e,n,r,s,o=this;this.progress=0,t=0,s=[],r=0,n=P(),e=setInterval(function(){var i;return i=P()-n-50,n=P(),s.push(i),s.length>E.eventLag.sampleCount&&s.shift(),t=m(s),++r>=E.eventLag.minSamples&&t<E.eventLag.lagThreshold?(o.progress=100,clearInterval(e)):o.progress=100*(3/(t+3))},50)}return t}(),h=function(){function t(t){this.source=t,this.last=this.sinceLastUpdate=0,this.rate=E.initialRate,this.catchup=0,this.progress=this.lastProgress=0,null!=this.source&&(this.progress=M(this.source,"progress"))}return t.prototype.tick=function(t,e){var n;return null==e&&(e=M(this.source,"progress")),e>=100&&(this.done=!0),e===this.last?this.sinceLastUpdate+=t:(this.sinceLastUpdate&&(this.rate=(e-this.last)/this.sinceLastUpdate),this.catchup=(e-this.progress)/E.catchupTime,this.sinceLastUpdate=0,this.last=e),e>this.progress&&(this.progress+=this.catchup*t),n=1-Math.pow(this.progress/100,E.easeFactor),this.progress+=n*this.rate*t,this.progress=Math.min(this.lastProgress+E.maxProgressPerFrame,this.progress),this.progress=Math.max(0,this.progress),this.progress=Math.min(100,this.progress),this.lastProgress=this.progress,this.progress},t}(),C=null,N=null,y=null,U=null,d=null,v=null,c.running=!1,x=function(){return E.restartOnPushState?c.restart():void 0},null!=window.history.pushState&&(B=window.history.pushState,window.history.pushState=function(){return x(),B.apply(window.history,arguments)}),null!=window.history.replaceState&&(Q=window.history.replaceState,window.history.replaceState=function(){return x(),Q.apply(window.history,arguments)}),p={ajax:t,elements:r,document:n,eventLag:o},(R=function(){var t,n,r,s,o,i,u,a;for(c.sources=C=[],i=["ajax","elements","document","eventLag"],n=0,s=i.length;s>n;n++)t=i[n],E[t]!==!1&&C.push(new p[t](E[t]));for(a=null!=(u=E.extraSources)?u:[],r=0,o=a.length;o>r;r++)F=a[r],C.push(new F(E));return c.bar=y=new e,N=[],U=new h})(),c.stop=function(){return c.trigger("stop"),c.running=!1,y.destroy(),v=!0,null!=d&&("function"==typeof w&&w(d),d=null),R()},c.restart=function(){return c.trigger("restart"),c.stop(),c.start()},c.go=function(){var t;return c.running=!0,y.render(),t=P(),v=!1,d=A(function(e,n){var r,s,o,i,u,a,l,p,g,f,d,m,w,b,k,S;for(p=100-y.progress,s=d=0,o=!0,a=m=0,b=C.length;b>m;a=++m)for(F=C[a],f=null!=N[a]?N[a]:N[a]=[],u=null!=(S=F.elements)?S:[F],l=w=0,k=u.length;k>w;l=++w)i=u[l],g=null!=f[l]?f[l]:f[l]=new h(i),o&=g.done,g.done||(s++,d+=g.tick(e));return r=d/s,y.update(U.tick(e,r)),y.done()||o||v?(y.update(100),c.trigger("done"),setTimeout(function(){return y.finish(),c.running=!1,c.trigger("hide")},Math.max(E.ghostTime,Math.max(E.minTime-(P()-t),0)))):n()})},c.start=function(t){k(E,t),c.running=!0;try{y.render()}catch(e){a=e}return document.querySelector(".pace")?(c.trigger("start"),c.go()):setTimeout(c.start,50)},"function"==typeof define&&define.amd?define(function(){return c}):"object"==typeof exports?module.exports=c:E.startOnPageLoad&&c.start()}).call(this);
2
+
1
3
  $(document).ajaxStart(function() { Pace.restart(); });
2
- var suffix = '.json';
3
4
  Vue.config.devtools = true;
4
5
  Pace.on('done', function() {
5
6
  $('#form-progress').val('0');
@@ -11,7 +12,7 @@ function sleep(time) {
11
12
  function obj_to_json(obj) {
12
13
  return JSON.parse(JSON.stringify(obj));
13
14
  }
14
- var model_row_mixin = {}
15
+ var models_mixin = {}
15
16
  var root_mixin = {}
16
17
  function updateQueryStringParam(key, value) {
17
18
  baseUrl = [location.protocol, '//', location.host, location.pathname].join('');
@@ -40,14 +41,19 @@ function getParameterByName(name) {
40
41
  if (!results[2]) return '';
41
42
  return decodeURIComponent(results[2].replace(/\+/g, " "));
42
43
  }
43
- function vue_init() {
44
+ function vue_init(params = {}) {
45
+ var default_options = {
46
+ suffix: '.json',
47
+ column_type: 'card'
48
+ }
49
+ var options = $.extend(true, {}, default_options, params)
44
50
  Vue.filter('datetime', function (value) {
45
51
  return new Date(value).toLocaleString();
46
52
  })
47
53
 
48
- var modelRowComponent = Vue.component('model-row', {
49
- mixins: [model_row_mixin],
50
- template: '#model-row',
54
+ var modelsComponent = Vue.component('models', {
55
+ mixins: [models_mixin],
56
+ template: '#models-' + options.column_type,
51
57
  props: {
52
58
  model: Object,
53
59
  selected_attribute: String,
@@ -93,7 +99,7 @@ function vue_init() {
93
99
  if(confirm("Are you sure?") == true) {
94
100
  $.ajax({
95
101
  method: 'DELETE',
96
- url: that.info.url_prefix + '/' + that.model.id + suffix,
102
+ url: that.info.url_prefix + '/' + that.model.id + options.suffix,
97
103
  success: function(res) {
98
104
  $(that.$el).remove();
99
105
  },
@@ -114,7 +120,7 @@ function vue_init() {
114
120
  data: {
115
121
  model: that.model,
116
122
  },
117
- url: that.info.url_prefix + '/' + that.model.id + suffix,
123
+ url: that.info.url_prefix + '/' + that.model.id + options.suffix,
118
124
  beforeSend: function() {
119
125
  modal.find('.dimmer').toggleClass('active');
120
126
  $('.progress-bar').css('width', '0');
@@ -140,10 +146,11 @@ function vue_init() {
140
146
  }
141
147
  })
142
148
 
143
- var modelsVue = new Vue({
149
+ var rootVue = new Vue({
144
150
  mixins: [root_mixin],
145
- el: '#models',
151
+ el: '#vue_crud',
146
152
  data: {
153
+ column_type: options.column_type,
147
154
  models: [],
148
155
  info: {
149
156
  url_prefix: '',
@@ -165,12 +172,12 @@ function vue_init() {
165
172
  mounted: function() {
166
173
  var that = this;
167
174
  $.ajax({
168
- url: window.location.pathname + '/info' + suffix,
175
+ url: window.location.pathname + '/info' + options.suffix,
169
176
  success: function(res) {
170
177
  that.info = res;
171
178
  that.model = obj_to_json(that.info.structure);
172
179
  $.ajax({
173
- url: that.info.url_prefix + suffix,
180
+ url: that.info.url_prefix + options.suffix,
174
181
  success: function(res) {
175
182
  that.models = res;
176
183
  }
@@ -256,7 +263,7 @@ function vue_init() {
256
263
  data: {
257
264
  model: that.model,
258
265
  },
259
- url: that.info.url_prefix + suffix,
266
+ url: that.info.url_prefix + options.suffix,
260
267
  before: function() {
261
268
  $('.new_modal').find('.dimmer').toggleClass('active');
262
269
  $('.progress-bar').css('width', '0');
@@ -1,8 +1,10 @@
1
+ .pace{-webkit-pointer-events:none;pointer-events:none;-webkit-user-select:none;-moz-user-select:none;user-select:none}.pace-inactive{display:none}.pace .pace-progress{background:#29d;position:fixed;z-index:2000;top:0;right:100%;width:100%;height:2px}
2
+
1
3
  .ui.cards > .card > .extra a.save_now {
2
4
  color: rgb(33, 133, 208);
3
5
  opacity: 1;
4
6
  }
5
- .progress {
7
+ .card .progress {
6
8
  margin-bottom: 0;
7
9
  border-radius: 0;
8
10
  height: 10px;
@@ -14,6 +16,18 @@
14
16
  .summary.highlight {
15
17
  border: 2px solid #a90000;
16
18
  }
19
+ th.highlight {
20
+ border: 2px solid #a90000 !important;
21
+ }
22
+ td.highlight {
23
+ border-left: 2px solid #a90000 !important;
24
+ border-right: 2px solid #a90000;
25
+ }
26
+ tbody tr:last-child td.highlight {
27
+ border-left: 2px solid #a90000 !important;
28
+ border-right: 2px solid #a90000;
29
+ border-bottom: 2px solid #a90000;
30
+ }
17
31
  .inline-block {
18
32
  display: inline-block;
19
33
  }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vue_crud
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Donald Chiang
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-11-02 00:00:00.000000000 Z
11
+ date: 2016-11-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler