@fleetbase/ember-core 0.1.3 → 0.1.5
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.
|
@@ -140,6 +140,19 @@ export default class UniverseService extends Service.extend(Evented) {
|
|
|
140
140
|
return this;
|
|
141
141
|
}
|
|
142
142
|
|
|
143
|
+
/**
|
|
144
|
+
* Triggers an event on for a universe registry.
|
|
145
|
+
*
|
|
146
|
+
* @memberof UniverseService
|
|
147
|
+
* @method createRegistryEvent
|
|
148
|
+
* @param {string} registryName - The name of the registry to trigger the event on.
|
|
149
|
+
* @param {string} event - The name of the event to trigger.
|
|
150
|
+
* @param {...*} params - Additional parameters to pass to the event handler.
|
|
151
|
+
*/
|
|
152
|
+
@action createRegistryEvent(registryName, event, ...params) {
|
|
153
|
+
this.trigger(`${registryName}.${event}`, ...params);
|
|
154
|
+
}
|
|
155
|
+
|
|
143
156
|
/**
|
|
144
157
|
* @action
|
|
145
158
|
* Retrieves the entire registry with the given name.
|
|
@@ -607,6 +620,7 @@ export default class UniverseService extends Service.extend(Evented) {
|
|
|
607
620
|
const items = this._getOption(options, 'items');
|
|
608
621
|
const component = this._getOption(options, 'component');
|
|
609
622
|
const componentParams = this._getOption(options, 'componentParams', {});
|
|
623
|
+
const renderComponentInPlace = this._getOption(options, 'renderComponentInPlace', false);
|
|
610
624
|
const slug = this._getOption(options, 'slug', dasherize(title));
|
|
611
625
|
const view = this._getOption(options, 'view');
|
|
612
626
|
const queryParams = this._getOption(options, 'queryParams', {});
|
|
@@ -631,20 +645,15 @@ export default class UniverseService extends Service.extend(Evented) {
|
|
|
631
645
|
items,
|
|
632
646
|
component,
|
|
633
647
|
componentParams,
|
|
648
|
+
renderComponentInPlace,
|
|
634
649
|
slug,
|
|
635
650
|
queryParams,
|
|
636
651
|
view,
|
|
637
652
|
index,
|
|
638
653
|
section,
|
|
654
|
+
onClick,
|
|
639
655
|
};
|
|
640
656
|
|
|
641
|
-
// send default params into onClick
|
|
642
|
-
if (typeof onClick === 'function') {
|
|
643
|
-
menuItem.onClick = () => {
|
|
644
|
-
return onClick(menuItem);
|
|
645
|
-
};
|
|
646
|
-
}
|
|
647
|
-
|
|
648
657
|
return menuItem;
|
|
649
658
|
}
|
|
650
659
|
|
|
@@ -677,6 +686,55 @@ export default class UniverseService extends Service.extend(Evented) {
|
|
|
677
686
|
}
|
|
678
687
|
}
|
|
679
688
|
|
|
689
|
+
/**
|
|
690
|
+
* Manually registers a service in a specified engine.
|
|
691
|
+
*
|
|
692
|
+
* @method registerComponentInEngine
|
|
693
|
+
* @public
|
|
694
|
+
* @memberof UniverseService
|
|
695
|
+
* @param {String} engineName - The name of the engine where the component should be registered.
|
|
696
|
+
* @param {Object} serviceClass - The service class to register, which should have a 'name' property.
|
|
697
|
+
*/
|
|
698
|
+
registerServiceInEngine(targetEngineName, serviceName, currentEngineInstance) {
|
|
699
|
+
// Get the target engine instance
|
|
700
|
+
const targetEngineInstance = this.getEngineInstance(targetEngineName);
|
|
701
|
+
|
|
702
|
+
// Validate inputs
|
|
703
|
+
if (targetEngineInstance && currentEngineInstance && typeof serviceName === 'string') {
|
|
704
|
+
// Lookup the service instance from the current engine
|
|
705
|
+
const sharedService = currentEngineInstance.lookup(`service:${serviceName}`);
|
|
706
|
+
|
|
707
|
+
if (sharedService) {
|
|
708
|
+
// Register the service in the target engine
|
|
709
|
+
targetEngineInstance.register(`service:${serviceName}`, sharedService, { instantiate: false });
|
|
710
|
+
}
|
|
711
|
+
}
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
/**
|
|
715
|
+
* Retrieves a service instance from a specified Ember engine.
|
|
716
|
+
*
|
|
717
|
+
* @param {string} engineName - The name of the engine from which to retrieve the service.
|
|
718
|
+
* @param {string} serviceName - The name of the service to retrieve.
|
|
719
|
+
* @returns {Object|null} The service instance if found, otherwise null.
|
|
720
|
+
*
|
|
721
|
+
* @example
|
|
722
|
+
* const userService = universe.getServiceFromEngine('user-engine', 'user');
|
|
723
|
+
* if (userService) {
|
|
724
|
+
* userService.doSomething();
|
|
725
|
+
* }
|
|
726
|
+
*/
|
|
727
|
+
getServiceFromEngine(engineName, serviceName) {
|
|
728
|
+
const engineInstance = this.getEngineInstance(engineName);
|
|
729
|
+
|
|
730
|
+
if (engineInstance && typeof serviceName === 'string') {
|
|
731
|
+
const serviceInstance = engineInstance.lookup(`service:${serviceName}`);
|
|
732
|
+
return serviceInstance;
|
|
733
|
+
}
|
|
734
|
+
|
|
735
|
+
return null;
|
|
736
|
+
}
|
|
737
|
+
|
|
680
738
|
/**
|
|
681
739
|
* Load the specified engine. If it is not loaded yet, it will use assetLoader
|
|
682
740
|
* to load it and then register it to the router.
|
|
@@ -90,7 +90,7 @@ export default function autoSerialize(model, except = []) {
|
|
|
90
90
|
}
|
|
91
91
|
|
|
92
92
|
if (kind === 'hasMany') {
|
|
93
|
-
serialized[attr] =
|
|
93
|
+
serialized[attr] = [];
|
|
94
94
|
} else {
|
|
95
95
|
serialized[attr] = serialize(model[attr]);
|
|
96
96
|
}
|
package/package.json
CHANGED