Skip to content

Commit 2e262fb

Browse files
committed
Remove use of '@' defining links and collections (fix #54)
1 parent f9fd517 commit 2e262fb

File tree

7 files changed

+163
-67
lines changed

7 files changed

+163
-67
lines changed

src/component.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ function _Array(conf) {
9191

9292
// init
9393
arrDb.forEach(function (val) {
94-
if (type.indexOf('@') !== -1) {
94+
if ($metamodel.isClassName(type)) {
9595
arr.push($helper.getRuntime().require(val));
9696
} else {
9797
arr.push(val);
@@ -106,7 +106,7 @@ function _Array(conf) {
106106

107107
if (!isReadOnly) {
108108

109-
isClass = type.indexOf('@') !== -1;
109+
isClass = $metamodel.isClassName(type);
110110

111111
if (isClass) {
112112
if (val && $metamodel.inheritFrom(val.constructor.name, type.replace('@', ''))) {
@@ -222,7 +222,7 @@ function _Array(conf) {
222222
});
223223
}
224224

225-
isClass = type.indexOf('@') !== -1;
225+
isClass = $metamodel.isClassName(type);
226226

227227
if (isClass) {
228228
result = store[val];
@@ -360,7 +360,7 @@ function _Array(conf) {
360360
length = result.length;
361361
for (i = 0; i < length; i++) {
362362

363-
isClass = type.indexOf('@') !== -1;
363+
isClass = $metamodel.isClassName(type);
364364
if (isClass) {
365365
data = store[result[i]];
366366
} else {
@@ -711,7 +711,7 @@ function addProperties(model, Class, classId) {
711711
if (
712712
!(
713713
$metamodel.isValidType(val, type) &&
714-
($metamodel.inheritFrom(val.constructor.name, type.replace('@', '')) && (type.indexOf('@') !== -1)))
714+
($metamodel.inheritFrom(val.constructor.name, type.replace('@', '')) && $metamodel.isClassName(type)))
715715
) {
716716
result = result && false;
717717
}
@@ -724,7 +724,7 @@ function addProperties(model, Class, classId) {
724724
var result = [];
725725

726726
coll.forEach(function (val) {
727-
if (type[0].indexOf('@') !== -1) {
727+
if ($metamodel.isClassName(type)) {
728728
switch (true) {
729729
case typeof val === 'string':
730730
result.push(val);
@@ -777,7 +777,7 @@ function addProperties(model, Class, classId) {
777777

778778
component = search[0];
779779
realVal = _getRealCollection(position, propertyType[0]);
780-
780+
781781
$workflow.state({
782782
'component': this.id(),
783783
'state': propertyName,
@@ -802,7 +802,7 @@ function addProperties(model, Class, classId) {
802802
if (typeof position === 'number') {
803803
val = $db.store[classId][this.id()][propertyName][position];
804804
if (val) {
805-
if (propertyType[0].indexOf('@') !== -1) {
805+
if ($metamodel.isClassName(propertyType[0])) {
806806
realVal = $helper.getRuntime().require(val);
807807
} else {
808808
realVal = val;
@@ -820,14 +820,14 @@ function addProperties(model, Class, classId) {
820820
} else {
821821
if (
822822
$metamodel.isValidType(value, propertyType[0]) ||
823-
($metamodel.inheritFrom(value.constructor.name, propertyType[0].replace('@', '')) && (propertyType[0].indexOf('@') !== -1))
823+
($metamodel.inheritFrom(value.constructor.name, propertyType[0].replace('@', '')) && $metamodel.isClassName(propertyType[0]))
824824
) {
825825
search = $db[classId].find({
826826
'_id': this.id()
827827
});
828828
if (search.length) {
829829

830-
if (propertyType[0].indexOf('@') !== -1) {
830+
if ($metamodel.isClassName(propertyType[0])) {
831831
switch (true) {
832832
case typeof value === 'string':
833833
realVal = value;
@@ -880,7 +880,7 @@ function addProperties(model, Class, classId) {
880880
component = $db.store[classId][this.id()];
881881
if (component) {
882882
switch (true) {
883-
case propertyType.indexOf('@') !== -1:
883+
case $metamodel.isClassName(propertyType):
884884
propertyValue = get(component[propertyName]);
885885
break;
886886
case propertyType === 'date':
@@ -920,7 +920,7 @@ function addProperties(model, Class, classId) {
920920
component = search[0];
921921

922922
switch (true) {
923-
case propertyType.indexOf('@') !== -1:
923+
case $metamodel.isClassName(propertyType):
924924
if (value === null) {
925925
component[propertyName] = value;
926926
} else {
@@ -1140,7 +1140,7 @@ function addStructure(path, name, model, id) {
11401140
component = $db.store[model][id];
11411141
if (component) {
11421142
switch (true) {
1143-
case propertyType.indexOf('@') !== -1:
1143+
case $metamodel.isClassName(propertyType):
11441144
propertyValue = get(getStructureValue(model, id, fullPath));
11451145
break;
11461146
case propertyType === 'date':
@@ -1173,7 +1173,7 @@ function addStructure(path, name, model, id) {
11731173
component = search[0];
11741174

11751175
switch (true) {
1176-
case propertyType.indexOf('@') !== -1:
1176+
case $metamodel.isClassName(propertyType):
11771177
setStructureValue(model, id, fullPath, value.id());
11781178
break;
11791179
case propertyType === 'date':

0 commit comments

Comments
 (0)