Skip to content

Commit 48d4f3d

Browse files
Erwan CarriouErwan Carriou
authored andcommitted
- add collections method on db component
- remove dependency injection of $db by default on behaviors - clean some behaviors
1 parent 4d110fe commit 48d4f3d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+363
-300
lines changed

addons/web.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,17 @@
3232
"_id": "1aaee1e6311ff39",
3333
"component": "monoco",
3434
"state": "load",
35-
"action": "function load(url, async) { var xhr = null, callbackLoad = null; xhr = new XMLHttpRequest(); callbackLoad = function callbackLoad(system) { var sysId = $db.system(system), sys = $component.get(sysId), systems = document.querySelectorAll('link[rel=system]'), nbSubsystem = $db.MonocoSystem.find({ 'subsystem': true }); if (sys) { sys.main(); } if (systems.length + 1 + nbSubsystem.length === $db.MonocoSystem.count()) { $component.get('monoco').ready(); } }; if (async) { xhr.open('GET', url, true); xhr.onreadystatechange = function () { if (xhr.readyState === 4) { if (xhr.status === 200) { callbackLoad(JSON.parse(xhr.response)); } } }; xhr.send(null); } else { xhr.open('GET', url, false); xhr.send(null); if (xhr.status === 200) { callbackLoad(JSON.parse(xhr.response)); } }}",
35+
"action": "function load(url, async) { var xhr = null, callbackLoad = null; xhr = new XMLHttpRequest(); callbackLoad = function callbackLoad(system) { var sysId = $db.system(system), sys = $component.get(sysId), systems = document.querySelectorAll('link[rel=system]'), nbSubsystem = $db.MonocoSystem.find({ 'subsystem': true }); if (sys) { sys.main(); } if (systems.length + 1 + nbSubsystem.length === $db.MonocoSystem.count()) { $component.get('monoco').ready(); } }; if (async) { xhr.open('GET', url, true); xhr.onreadystatechange = function () { if (xhr.readyState === 4) { if (xhr.status === 200) { callbackLoad(JSON.parse(xhr.response)); } } }; xhr.send(null); } else { xhr.open('GET', url, false); xhr.send(null); if (xhr.status === 200) { callbackLoad(JSON.parse(xhr.response)); } }}",
3636
"core": true,
3737
"useCoreAPI": true
3838
},
3939
"1f6001773a18791": {
4040
"_id": "1f6001773a18791",
4141
"component": "e89c617b6b15d24",
4242
"state": "main",
43-
"action": "function main() { var subsystems = [], systems = [], system = null, i = 0, length = 0; subsystems = $db.MonocoSystem.find({ 'subsystem': true }); subsystems.forEach(function (subsystem) { var subsystemId = subsystem._id; this.require(subsystemId).main(); }, this); if (typeof document !== 'undefined') { systems = document.querySelectorAll('link[rel=system]'); length = systems.length; for (i = 0; i < length; i++) { system = systems[i]; if (system.getAttribute('async') === 'false') { this.require('monoco').load(system.href, false); } else { this.require('monoco').load(system.href, true); } } if (length === 0) { this.require('monoco').ready(); } }}",
44-
"core": true
43+
"action": "function main() { var subsystems = [], systems = [], system = null, i = 0, length = 0; subsystems = $db.MonocoSystem.find({ 'subsystem': true }); subsystems.forEach(function (subsystem) { var subsystemId = subsystem._id; this.require(subsystemId).main(); }, this); if (typeof document !== 'undefined') { systems = document.querySelectorAll('link[rel=system]'); length = systems.length; for (i = 0; i < length; i++) { system = systems[i]; if (system.getAttribute('async') === 'false') { this.require('monoco').load(system.href, false); } else { this.require('monoco').load(system.href, true); } } if (length === 0) { this.require('monoco').ready(); } }}",
44+
"core": true,
45+
"useCoreAPI": true
4546
}
4647
},
4748
"components": {}

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "monoco",
3-
"version": "0.7.1",
3+
"version": "0.7.2",
44
"description": "A Model and a NoSQL Database for Components",
55
"license": "GPL-3.0",
66
"homepage": "https://github.com/monocojs/monoco.git",

build/monoco-min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/monoco.js

Lines changed: 63 additions & 54 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/monoco.json

Lines changed: 62 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "monoco",
3-
"version": "0.7.1",
3+
"version": "0.7.2",
44
"description": "A Model and a NoSQL Database for Components",
55
"_id": "e89c617b6b15d24",
66
"schemas": {
@@ -352,6 +352,9 @@
352352
],
353353
"result": "string"
354354
},
355+
"collections": {
356+
"result": "object"
357+
},
355358
"insert": {
356359
"params": [
357360
{
@@ -406,6 +409,7 @@
406409
"_core": true,
407410
"system": "method",
408411
"subsystem": "method",
412+
"collections": "method",
409413
"insert": "event",
410414
"update": "event",
411415
"remove": "event"
@@ -751,177 +755,186 @@
751755
"_id": "1aaee1e6311ff39",
752756
"component": "monoco",
753757
"state": "load",
754-
"action": "function load(url, async) { var xhr = null, callbackLoad = null; xhr = new XMLHttpRequest(); callbackLoad = function callbackLoad(system) { var sysId = $db.system(system), sys = $component.get(sysId), systems = document.querySelectorAll('link[rel=system]'), nbSubsystem = $db.MonocoSystem.find({ 'subsystem': true }); if (sys) { sys.main(); } if (systems.length + 1 + nbSubsystem.length === $db.MonocoSystem.count()) { $component.get('monoco').ready(); } }; if (async) { xhr.open('GET', url, true); xhr.onreadystatechange = function () { if (xhr.readyState === 4) { if (xhr.status === 200) { callbackLoad(JSON.parse(xhr.response)); } } }; xhr.send(null); } else { xhr.open('GET', url, false); xhr.send(null); if (xhr.status === 200) { callbackLoad(JSON.parse(xhr.response)); } }}",
758+
"action": "function load(url, async) { var xhr = null, callbackLoad = null; xhr = new XMLHttpRequest(); callbackLoad = function callbackLoad(system) { var sysId = $db.system(system), sys = $component.get(sysId), systems = document.querySelectorAll('link[rel=system]'), nbSubsystem = $db.MonocoSystem.find({ 'subsystem': true }); if (sys) { sys.main(); } if (systems.length + 1 + nbSubsystem.length === $db.MonocoSystem.count()) { $component.get('monoco').ready(); } }; if (async) { xhr.open('GET', url, true); xhr.onreadystatechange = function () { if (xhr.readyState === 4) { if (xhr.status === 200) { callbackLoad(JSON.parse(xhr.response)); } } }; xhr.send(null); } else { xhr.open('GET', url, false); xhr.send(null); if (xhr.status === 200) { callbackLoad(JSON.parse(xhr.response)); } }}",
755759
"core": true,
756760
"useCoreAPI": true
757761
},
758762
"1f6001773a18791": {
759763
"_id": "1f6001773a18791",
760764
"component": "e89c617b6b15d24",
761765
"state": "main",
762-
"action": "function main() { var subsystems = [], systems = [], system = null, i = 0, length = 0; subsystems = $db.MonocoSystem.find({ 'subsystem': true }); subsystems.forEach(function (subsystem) { var subsystemId = subsystem._id; this.require(subsystemId).main(); }, this); if (typeof document !== 'undefined') { systems = document.querySelectorAll('link[rel=system]'); length = systems.length; for (i = 0; i < length; i++) { system = systems[i]; if (system.getAttribute('async') === 'false') { this.require('monoco').load(system.href, false); } else { this.require('monoco').load(system.href, true); } } if (length === 0) { this.require('monoco').ready(); } }}",
763-
"core": true
766+
"action": "function main() { var subsystems = [], systems = [], system = null, i = 0, length = 0; subsystems = $db.MonocoSystem.find({ 'subsystem': true }); subsystems.forEach(function (subsystem) { var subsystemId = subsystem._id; this.require(subsystemId).main(); }, this); if (typeof document !== 'undefined') { systems = document.querySelectorAll('link[rel=system]'); length = systems.length; for (i = 0; i < length; i++) { system = systems[i]; if (system.getAttribute('async') === 'false') { this.require('monoco').load(system.href, false); } else { this.require('monoco').load(system.href, true); } } if (length === 0) { this.require('monoco').ready(); } }}",
767+
"core": true,
768+
"useCoreAPI": true
764769
},
765-
"1882e182f0152e8": {
766-
"_id": "1882e182f0152e8",
770+
"1302e13eed1a03c": {
771+
"_id": "1302e13eed1a03c",
767772
"component": "Monoco",
768773
"state": "error",
769774
"action": "function error(data) { console.error('monoco: ' + data.message, data.error); }",
770775
"core": true
771776
},
772-
"1e66a1cb471f725": {
773-
"_id": "1e66a1cb471f725",
777+
"16c471e4941c644": {
778+
"_id": "16c471e4941c644",
774779
"component": "Monoco",
775780
"state": "system",
776781
"action": "function system(name) { var System = null, system = {}, systemId = '', result = [], conf = {}; if (name) { conf.master = true; conf.name = name; System = this.require('MonocoSystem'); system = new System(conf); } else { result = $db.MonocoSystem.find({ 'master': true }); if (result.length) { systemId = result[0]._id; system = $component.get(systemId); } } return system;}",
777782
"core": true,
778783
"useCoreAPI": true
779784
},
780-
"120b21065b1ae99": {
781-
"_id": "120b21065b1ae99",
785+
"13b7f1fb671e39d": {
786+
"_id": "13b7f1fb671e39d",
782787
"component": "Monoco",
783788
"state": "warning",
784789
"action": "function warning(message) { console.warn('monoco: ' + message); }",
785790
"core": true
786791
},
787-
"198be1c2ac1a1c2": {
788-
"_id": "198be1c2ac1a1c2",
792+
"10f95179ec1aac4": {
793+
"_id": "10f95179ec1aac4",
789794
"component": "MonocoChannel",
790795
"state": "listen",
791796
"action": "function listen(event, action) { $channel.listen(event, action); }",
792797
"core": true,
793798
"useCoreAPI": true
794799
},
795-
"14ec91c6431ca5a": {
796-
"_id": "14ec91c6431ca5a",
800+
"132421889f1eb42": {
801+
"_id": "132421889f1eb42",
797802
"component": "MonocoChannel",
798803
"state": "send",
799804
"action": "function send(message) { return $channel.send(message); }",
800805
"core": true,
801806
"useCoreAPI": true
802807
},
803-
"1d96117d2c1de48": {
804-
"_id": "1d96117d2c1de48",
808+
"198191d211179d9": {
809+
"_id": "198191d211179d9",
805810
"component": "MonocoClassInfo",
806811
"state": "collection",
807812
"action": "function collection(name) { var result = {}; if (this.metamodel()[name] === 'collection') { result = this.model()[name]; } return result; }",
808813
"core": true
809814
},
810-
"1542e1e5681dbe0": {
811-
"_id": "1542e1e5681dbe0",
815+
"194cb1cfe412ae0": {
816+
"_id": "194cb1cfe412ae0",
812817
"component": "MonocoClassInfo",
813818
"state": "collections",
814819
"action": "function collections() { var keys = Object.keys(this.metamodel()), item = '', result = [], i = 0, length = 0; length = keys.length; for (i = 0; i < length; i++) { item = keys[i]; if (this.metamodel()[item] === 'collection') { result.push(item); } } return result; }",
815820
"core": true
816821
},
817-
"1afd6137641e9eb": {
818-
"_id": "1afd6137641e9eb",
822+
"198d71966b1d628": {
823+
"_id": "198d71966b1d628",
819824
"component": "MonocoClassInfo",
820825
"state": "event",
821826
"action": "function event(name) { var result = {}; if (this.metamodel()[name] === 'event') { result = this.model()[name]; } return result; }",
822827
"core": true
823828
},
824-
"1de7c1f23416fbc": {
825-
"_id": "1de7c1f23416fbc",
829+
"167181f3ce19fcc": {
830+
"_id": "167181f3ce19fcc",
826831
"component": "MonocoClassInfo",
827832
"state": "events",
828833
"action": "function events() { var keys = Object.keys(this.metamodel()), item = '', result = [], i = 0, length = 0; length = keys.length; for (i = 0; i < length; i++) { item = keys[i]; if (this.metamodel()[item] === 'event') { result.push(item); } } return result; }",
829834
"core": true
830835
},
831-
"1bdc41626b12c74": {
832-
"_id": "1bdc41626b12c74",
836+
"164461951412489": {
837+
"_id": "164461951412489",
833838
"component": "MonocoClassInfo",
834839
"state": "method",
835840
"action": "function method(name) { var result = {}; if (this.metamodel()[name] === 'method') { result = this.model()[name]; } return result; }",
836841
"core": true
837842
},
838-
"11f651f4aa1e32a": {
839-
"_id": "11f651f4aa1e32a",
843+
"1007a10e6a1dc4c": {
844+
"_id": "1007a10e6a1dc4c",
840845
"component": "MonocoClassInfo",
841846
"state": "methods",
842847
"action": "function methods() { var keys = Object.keys(this.metamodel()), item = '', result = [], i = 0, length = 0; length = keys.length; for (i = 0; i < length; i++) { item = keys[i]; if (this.metamodel()[item] === 'method') { result.push(item); } } return result; }",
843848
"core": true
844849
},
845-
"1fd2114fd71280b": {
846-
"_id": "1fd2114fd71280b",
850+
"190d01cc3c12f1c": {
851+
"_id": "190d01cc3c12f1c",
847852
"component": "MonocoClassInfo",
848853
"state": "properties",
849854
"action": "function properties() { var keys = Object.keys(this.metamodel()), item = '', result = [], i = 0, length = 0; length = keys.length; for (i = 0; i < length; i++) { item = keys[i]; if (this.metamodel()[item] === 'property') { result.push(item); } } return result; }",
850855
"core": true
851856
},
852-
"14f6e1a5d81d4fd": {
853-
"_id": "14f6e1a5d81d4fd",
857+
"1d68e1baf01a0c2": {
858+
"_id": "1d68e1baf01a0c2",
854859
"component": "MonocoClassInfo",
855860
"state": "property",
856861
"action": "function property(name) { var result = {}; if (this.metamodel()[name] === 'property') { result = this.model()[name]; } return result; }",
857862
"core": true
858863
},
859-
"10d1a1683d16dc4": {
860-
"_id": "10d1a1683d16dc4",
864+
"1eba111bd3151a6": {
865+
"_id": "1eba111bd3151a6",
861866
"component": "MonocoComponent",
862867
"state": "destroy",
863868
"action": "function destroy() { $component.destroy(this.id()); }",
864869
"core": true,
865870
"useCoreAPI": true
866871
},
867-
"1105419a6f1519c": {
868-
"_id": "1105419a6f1519c",
872+
"101a814f6c10c62": {
873+
"_id": "101a814f6c10c62",
869874
"component": "MonocoComponent",
870875
"state": "off",
871876
"action": "function off(state, behaviorId) { var args = [], i = 0, length = 0; length = arguments.length; for (i = 0; i < length - 7; i++) { args.push(arguments[i]); } if ($workflow.checkParams({\"component\": this, \"methodName\": \"off\", \"args\": args})) { if ($metamodel.isValidState(state, this.constructor.name)) {$behavior.remove({\"behaviorId\": behaviorId, \"componentId\": this.id(), \"state\": state}); } else { $helper.getMonoco().warning({ \"message\":\"invoke 'off' method of component '\" + this.id() + \"' with an invalid state '\" + state + \"'\"}); } } }",
872877
"core": true,
873878
"useCoreAPI": true
874879
},
875-
"15b2b18f0c1a0f7": {
876-
"_id": "15b2b18f0c1a0f7",
880+
"1f5471a45a1807d": {
881+
"_id": "1f5471a45a1807d",
877882
"component": "MonocoComponent",
878883
"state": "require",
879884
"action": "function require(id) { return $component.get(id); }",
880885
"core": true,
881886
"useCoreAPI": true
882887
},
883-
"1a6791cfba179e4": {
884-
"_id": "1a6791cfba179e4",
888+
"1883010e0314a1c": {
889+
"_id": "1883010e0314a1c",
890+
"component": "MonocoDatabase",
891+
"state": "collections",
892+
"action": "function collections() { var result = {}, collectionName = ''; for (collectionName in $db.store) { if ($db.store.hasOwnProperty(collectionName) && collectionName.indexOf('Monoco') !== 0) { result[collectionName] = $db[collectionName]; } } return result;}",
893+
"core": true,
894+
"useCoreAPI": true
895+
},
896+
"1dc8413ead1f809": {
897+
"_id": "1dc8413ead1f809",
885898
"component": "MonocoDatabase",
886899
"state": "subsystem",
887900
"action": "function subsystem(params) { return $db.subsystem(params); }",
888901
"core": true,
889902
"useCoreAPI": true
890903
},
891-
"1a54f1adeb14122": {
892-
"_id": "1a54f1adeb14122",
904+
"18be21f3ca18c8a": {
905+
"_id": "18be21f3ca18c8a",
893906
"component": "MonocoDatabase",
894907
"state": "system",
895908
"action": "function system(system) { return $db.system(system); }",
896909
"core": true,
897910
"useCoreAPI": true
898911
},
899-
"14c601a2891aa34": {
900-
"_id": "14c601a2891aa34",
912+
"1ca4315f921ecb7": {
913+
"_id": "1ca4315f921ecb7",
901914
"component": "MonocoMetamodel",
902915
"state": "create",
903916
"action": "function create() { $metamodel.create(); }",
904917
"core": true,
905918
"useCoreAPI": true
906919
},
907-
"1170514b5a18985": {
908-
"_id": "1170514b5a18985",
920+
"18cfc1917c1ab4b": {
921+
"_id": "18cfc1917c1ab4b",
909922
"component": "MonocoMetamodel",
910923
"state": "schema",
911924
"action": "function schema(schema) { $metamodel.schema(schema); }",
912925
"core": true,
913926
"useCoreAPI": true
914927
},
915-
"113671115f1f368": {
916-
"_id": "113671115f1f368",
928+
"1dcfb187dd1035a": {
929+
"_id": "1dcfb187dd1035a",
917930
"component": "MonocoMetamodel",
918931
"state": "type",
919932
"action": "function type(type) { $metamodel.type(type); }",
920933
"core": true,
921934
"useCoreAPI": true
922935
},
923-
"1173f18bbd16418": {
924-
"_id": "1173f18bbd16418",
936+
"160fc1a46b11495": {
937+
"_id": "160fc1a46b11495",
925938
"component": "MonocoSystem",
926939
"state": "sync",
927940
"action": "function sync() { var system = JSON.parse($db.system()); this.schemas(system.schemas); this.types(system.types); this.behaviors(system.behaviors); this.components(system.components); }",
@@ -933,7 +946,7 @@
933946
"Monoco": {
934947
"monoco": {
935948
"_id": "monoco",
936-
"version": "0.7.1"
949+
"version": "0.7.2"
937950
}
938951
},
939952
"MonocoChannel": {

0 commit comments

Comments
 (0)