material_raingular 0.2.5 → 0.2.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/assets/javascripts/extensions.coffee +6 -2
- data/lib/assets/javascripts/material_raingular/directives/create/directive.coffee +4 -0
- data/lib/assets/javascripts/material_raingular/directives/create/linkmodel.coffee +54 -0
- data/lib/assets/javascripts/material_raingular/directives/destroy/linkmodel.coffee +4 -3
- data/lib/assets/javascripts/material_raingular/directives/update/linkmodel.coffee +1 -1
- data/lib/assets/javascripts/super_classes/material_modal_model.coffee +1 -2
- data/lib/material_raingular/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c40f07d0a41e9e977d2f0741e78dc032cb6b255c
|
4
|
+
data.tar.gz: 5cb872737925795da991f4cc2b7272a32b5f7480
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 14915454e93d749722bd13aebbdecc5baea09465b2fb7732cb74b36913a4104d2aee5d4f6fcab2861e8af0130c20c51bdaef4bc7b26c09d22a782ade0bd31f0a
|
7
|
+
data.tar.gz: 4e9ae92aeb2cdcb49434b85c854dd0895eaecf484f51e68e3c09ce6a52a124050a0223583e3c50a667d2231585a3d41bdbb00e418bb3a59ef9efe6dcc4dadbd5
|
@@ -43,9 +43,13 @@ Array.prototype.sum = ->
|
|
43
43
|
total += parseFloat(i) if i
|
44
44
|
total
|
45
45
|
Array.prototype.includes = (entry)->
|
46
|
-
|
46
|
+
return @.indexOf(entry) > -1 unless entry
|
47
|
+
if entry instanceof Date
|
48
|
+
(@.map (obj) -> obj.toDateString()).includes(entry.toDateString())
|
49
|
+
else if entry.hasOwnProperty('id')
|
50
|
+
return @.pluck('id').includes(entry.id)
|
51
|
+
else
|
47
52
|
return @.indexOf(entry) > -1
|
48
|
-
@.pluck('id').includes(entry.id)
|
49
53
|
Array.prototype.drop = (entry)->
|
50
54
|
if (entry || {}).hasOwnProperty('id')
|
51
55
|
index = @.pluck('id').indexOf(entry.id)
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# //= require material_raingular/directives/create/directive
|
2
|
+
class MrCreateModel extends AngularLinkModel
|
3
|
+
@inject(
|
4
|
+
'$injector'
|
5
|
+
'$timeout'
|
6
|
+
'factoryName'
|
7
|
+
'$parse'
|
8
|
+
)
|
9
|
+
|
10
|
+
initialize: ->
|
11
|
+
@$element.bind 'click', @create
|
12
|
+
@CallbackCtrl = @$controller
|
13
|
+
create: ($event) =>
|
14
|
+
factory = @_parentFactory()?['create_' + @_modelName().singularize()] || @_factory().create
|
15
|
+
factory @_params(), (data) =>
|
16
|
+
@CallbackCtrl.evaluate(data) if @CallbackCtrl
|
17
|
+
@$timeout =>
|
18
|
+
if @_isCollection()
|
19
|
+
@_models().last().push(data)
|
20
|
+
else
|
21
|
+
@_parentModel()[@_modelName()] = data
|
22
|
+
|
23
|
+
#Private
|
24
|
+
_modelPieces: ->
|
25
|
+
@$attrs.mrCreate.split(/\.|\[/).map (piece) =>
|
26
|
+
if piece.includes(']') then @$scope.$eval(piece.replace(/\]/,'')) else piece
|
27
|
+
_models: ->
|
28
|
+
models = [@$scope]
|
29
|
+
for piece,index in @_modelPieces()
|
30
|
+
models.push @$parse(piece)(models[index])
|
31
|
+
models
|
32
|
+
_modelName: ->
|
33
|
+
@$attrs.mrModelName || @_modelPieces().last()
|
34
|
+
_model: ->
|
35
|
+
@_models().last()
|
36
|
+
_parentModelName: ->
|
37
|
+
@_modelPieces()[@_modelPieces().length - 2]
|
38
|
+
_parentModel: ->
|
39
|
+
@_models()[@_models().length - 2]
|
40
|
+
_factory: ->
|
41
|
+
@$injector.get @factoryName(@_modelName()).singularize()
|
42
|
+
_parentFactory: ->
|
43
|
+
return unless @_parentModelName()
|
44
|
+
@$injector.get @factoryName(@_parentModelName()).singularize()
|
45
|
+
_params: ->
|
46
|
+
params={}
|
47
|
+
params[@_modelName().singularize()] = {}
|
48
|
+
if @_parentModelName()
|
49
|
+
params[@_modelName().singularize()][@_parentModelName().singularize() + '_id'] = @_parentModel().id
|
50
|
+
params[@_parentModelName().singularize() + '_id'] = @_parentModel().id
|
51
|
+
params
|
52
|
+
_isCollection: ->
|
53
|
+
@_modelName().pluralize() == @_modelName()
|
54
|
+
@register(Directives.MrCreate)
|
@@ -25,11 +25,12 @@ class MrDestroyModel extends AngularLinkModel
|
|
25
25
|
_model: -> @$controller[0].$viewValue
|
26
26
|
_list: -> @_options().list || @$scope.$eval(@_matchedExpression()[2].split('|')[0])
|
27
27
|
_options: -> @$scope.$eval(@$attrs.mrOptions || '{}')
|
28
|
-
_matchedExpression: -> @
|
28
|
+
_matchedExpression: -> @_repeatStatement().match(@REGEXP)
|
29
|
+
_repeatStatement: -> @_repeatElement().getAttribute('ng-repeat') || @_repeatElement().getAttribute('md-virtual-repeat')
|
29
30
|
_repeatElement: ->
|
30
31
|
repeatElement = @$element[0]
|
31
|
-
until repeatElement.hasAttribute
|
32
|
-
repeatElement = repeatElement.
|
32
|
+
until repeatElement.hasAttribute('ng-repeat') || repeatElement.hasAttribute('md-virtual-repeat')
|
33
|
+
repeatElement = repeatElement.parentElement
|
33
34
|
break if !repeatElement
|
34
35
|
repeatElement
|
35
36
|
_setForm: ->
|
@@ -48,7 +48,7 @@ class DirectiveModels.MrUpdateModel extends AngularLinkModel
|
|
48
48
|
_type: -> @$attrs.type
|
49
49
|
_tagName: -> @$element[0].tagName
|
50
50
|
_modelName: -> @$attrs.ngModel
|
51
|
-
_modelVal: ->
|
51
|
+
_modelVal: -> @ngModelCtrl.$modelValue
|
52
52
|
_isInput: -> @_tagName() == 'INPUT'
|
53
53
|
_funcName: ->
|
54
54
|
return 'textarea' if @_tagName() == 'TEXTAREA'
|
@@ -15,8 +15,7 @@ class @MaterialModalModel extends AngularScopedModel
|
|
15
15
|
@[key] = args[index]
|
16
16
|
for key in @constructor.$locals || []
|
17
17
|
@$scope[key] = @[key]
|
18
|
-
@$scope.hide
|
19
|
-
@$scope.cancel = @$mdDialog.hide
|
18
|
+
@$scope.hide = @$scope.cancel = @$scope.close = @$mdDialog.hide
|
20
19
|
|
21
20
|
# Bind all functions not begining with _ to scope
|
22
21
|
for key, val of @constructor.prototype
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: material_raingular
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Moody
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-11-
|
11
|
+
date: 2016-11-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -105,6 +105,8 @@ files:
|
|
105
105
|
- lib/assets/javascripts/material_raingular.js.coffee
|
106
106
|
- lib/assets/javascripts/material_raingular/directives/callback/controller.coffee
|
107
107
|
- lib/assets/javascripts/material_raingular/directives/callback/directive.coffee
|
108
|
+
- lib/assets/javascripts/material_raingular/directives/create/directive.coffee
|
109
|
+
- lib/assets/javascripts/material_raingular/directives/create/linkmodel.coffee
|
108
110
|
- lib/assets/javascripts/material_raingular/directives/destroy/directive.coffee
|
109
111
|
- lib/assets/javascripts/material_raingular/directives/destroy/linkmodel.coffee
|
110
112
|
- lib/assets/javascripts/material_raingular/directives/update/directive.coffee
|