material_raingular 0.0.2.6.3 → 0.0.2.6.4
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 99e2764bb91cef98f71c86ee1e3ebb9a239e139a
|
4
|
+
data.tar.gz: 3917f56d7bfcdc2d8a34d64ea936e12566983b25
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 117c42b8e76b631a1c02cd4b16d27ee4c6ab029fcfe4a0070d0c2b6d6acb2a47d07dd84ff7d6051ba2a1ddc600f358b73469de99d05289e3e8f3f2bfa24e571b
|
7
|
+
data.tar.gz: 0da0ba314d5ee2070f4fe0a96d0f8832797858ffcf8417ac945c37b82ae90772e7a8132c91eb87581e83d815b738929e4a4a5c4bc6722ce9d1d5e38a62538f98
|
@@ -1,32 +1,33 @@
|
|
1
1
|
angular.module 'NgCreate', ['Factories', 'FactoryName']
|
2
2
|
|
3
|
-
.directive 'ngCreate', ($
|
3
|
+
.directive 'ngCreate', ($injector, factoryName) ->
|
4
4
|
restrict: 'A'
|
5
|
-
|
5
|
+
require: '?ngCallback'
|
6
|
+
link: (scope, element, attributes, ngCallbackCtrl) ->
|
6
7
|
element.bind 'click', (event) ->
|
7
8
|
[parentName, listName] = attributes.ngContext.split('.') if attributes.ngContext
|
8
9
|
attr = scope.$eval('(' + attributes.ngAttributes + ')') || {}
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
addTo = $element[0].attributes['ng-add-to'].value if $element[0].attributes['ng-add-to']
|
10
|
+
create(attributes.ngCreate,parentName,listName,attr)
|
11
|
+
create = (modelName,parentName,listName,attributes) ->
|
12
|
+
addTo = element[0].attributes['ng-add-to'].value if element[0].attributes['ng-add-to']
|
13
13
|
factory = factoryName(modelName)
|
14
14
|
list = $injector.get(factory)
|
15
15
|
object = {}
|
16
16
|
object[modelName] = attributes
|
17
17
|
if parentName
|
18
|
-
object[modelName][parentName] =
|
19
|
-
object[modelName][parentName + '_id'] =
|
20
|
-
object[parentName] =
|
21
|
-
object[parentName + '_id'] =
|
18
|
+
object[modelName][parentName] = scope[parentName] unless parentName.indexOf('_id') < 0
|
19
|
+
object[modelName][parentName + '_id'] = scope[parentName].id if parentName.indexOf('_id') < 0
|
20
|
+
object[parentName] = scope[parentName] unless parentName.indexOf('_id') < 0
|
21
|
+
object[parentName + '_id'] = scope[parentName].id if parentName.indexOf('_id') < 0
|
22
22
|
list.create object, (returnData) ->
|
23
23
|
if addTo
|
24
|
-
|
24
|
+
scope[addTo].push(returnData)
|
25
25
|
if listName
|
26
|
-
scope = if
|
26
|
+
scope = if scope[parentName] then scope else scope.$parent
|
27
27
|
scope[parentName] = {} unless scope[parentName]
|
28
28
|
scope[parentName][listName] = [] unless scope[parentName][listName]
|
29
29
|
scope[parentName][listName].push(returnData)
|
30
30
|
else
|
31
|
-
|
32
|
-
|
31
|
+
scope[factory] = [] unless scope[factory]
|
32
|
+
scope[factory].push(returnData)
|
33
|
+
ngCallbackCtrl.evaluate(returnData) if !!ngCallbackCtrl
|
@@ -1,24 +1,21 @@
|
|
1
1
|
angular.module 'NgDestroy', ['Factories']
|
2
2
|
|
3
|
-
.directive 'ngDestroy', ($
|
3
|
+
.directive 'ngDestroy', ($injector, factoryName) ->
|
4
4
|
restrict: 'A'
|
5
|
-
|
5
|
+
require: '?ngCallback'
|
6
|
+
link: (scope, element, attributes, ngCallbackCtrl) ->
|
6
7
|
element.bind 'click', (event) ->
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
raw_factory = modelName.split('_')
|
11
|
-
factory=[]
|
12
|
-
for word in raw_factory
|
13
|
-
factory.push(word.charAt(0).toUpperCase() + word.slice(1))
|
14
|
-
factory = factory.join('')
|
8
|
+
destroy(attributes.ngDestroy,attributes.ngContext)
|
9
|
+
destroy = (modelName,listName) ->
|
10
|
+
factory = factoryName(modelName)
|
15
11
|
if listName
|
16
|
-
list =
|
12
|
+
list = scope
|
17
13
|
for scope in listName.split('.')
|
18
14
|
list = list[scope]
|
19
15
|
else
|
20
|
-
list =
|
21
|
-
list.
|
16
|
+
list = scope[factory]
|
17
|
+
list.drop(scope[modelName])
|
22
18
|
list = $injector.get(factory)
|
23
|
-
object = {id:
|
24
|
-
list.delete object
|
19
|
+
object = {id: scope[modelName].id}
|
20
|
+
list.delete object, (returnData)->
|
21
|
+
ngCallbackCtrl.evaluate(returnData) if !!ngCallbackCtrl
|