@sgcloud-sgsistemas/base 1.0.32 → 1.0.33

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sgcloud-sgsistemas/base",
3
- "version": "1.0.32",
3
+ "version": "1.0.33",
4
4
  "description": "Base para os sistemas da mobiage",
5
5
  "repository": {
6
6
  "type": "private",
@@ -22,6 +22,7 @@
22
22
  <label>{{module.label}}</label>
23
23
  </div>
24
24
  </module>
25
+
25
26
  <module ng-repeat="module in vm.config.structure"
26
27
  ng-if="module.label && module.children"
27
28
  ng-hide="vm.forceHide"
@@ -29,15 +30,49 @@
29
30
  ng-click="vm.onClickModule($index)"
30
31
  id="sg-hotbar-module-{{$index}}">
31
32
  <div>
32
- <i ng-if="module.icon && module.icon != ''"
33
- class="{{module.icon}}">
33
+ <i ng-if="module.icon && module.icon != ''"
34
+ class="{{module.icon}}">
34
35
  </i>
35
36
  <label>{{module.label}}</label>
36
37
  </div>
38
+
39
+ <sub-module id="sg-hotbar-sub-modules-{{$index}}"
40
+ class="favorite-module"
41
+ ng-if="$first && !!module.children && !module.children.length">
42
+ <div>
43
+ <label ng-click="vm.goToFavoritesConfig()">
44
+ Não há favoritos configurados
45
+ </label>
46
+ </div>
47
+ </sub-module>
48
+
49
+ <sub-module id="sg-hotbar-sub-modules-{{$index}}"
50
+ class="favorite-module"
51
+ ng-style="::vm.getSubModuleStyle($index)"
52
+ ng-if="$first && !!module.children && module.children.length"
53
+ ng-class="{'has-forced-hover': vm.openedFavoriteGroupIndex !== undefined }">
54
+ <div ng-repeat="favoriteGroup in module.children"
55
+ ng-if="!favoriteGroup.hide && favoriteGroup.children"
56
+ ng-class="{'force-open-favorite-group': vm.openedFavoriteGroupIndex == $index}"
57
+ ng-click="vm.onFavoriteGroupSelected($index)">
58
+ <label>{{favoriteGroup.label}}</label>
59
+
60
+ <div id="sg-hotbar-favorite-submodules-{{$index}}"
61
+ class="favorite-submodule"
62
+ ng-style="::vm.getFavoriteSubmodulesStyle($index)">
63
+ <div ng-repeat="favoriteSubmodule in favoriteGroup.children"
64
+ ng-click="vm.onSubModuleSelected(favoriteSubmodule, false, $event)">
65
+ <label>{{favoriteSubmodule.label}}</label>
66
+ </div>
67
+ </div>
68
+ </div>
69
+ </sub-module>
70
+
37
71
  <sub-module ng-style="::vm.getSubModuleStyle($index)"
38
- id="sg-hotbar-sub-modules-{{$index}}">
39
- <div ng-if="!subModule.hide"
40
- ng-repeat="subModule in module.children"
72
+ id="sg-hotbar-sub-modules-{{$index}}"
73
+ ng-if="!$first">
74
+ <div ng-repeat="subModule in module.children"
75
+ ng-if="!subModule.hide"
41
76
  ng-click="vm.onSubModuleSelected(subModule, false, $event)">
42
77
  <i class="{{subModule.icon}}"></i>
43
78
  <label>{{subModule.label}}</label>
@@ -138,13 +138,41 @@ hotbar {
138
138
  @include transition((grid-template-columns, left));
139
139
  position: absolute;
140
140
  z-index: -1;
141
- overflow-y: scroll;
142
141
 
143
- >* {
142
+ &:not(.favorite-module) {
143
+ overflow-y: scroll;
144
+ }
145
+
146
+ &.favorite-module {
147
+ box-shadow: none;
148
+ padding: 0;
149
+ gap: 0;
150
+
151
+ > div {
152
+ box-shadow: 4px 8px 10px -2px #00000066;
153
+ padding: 7.5px 10px;
154
+ background-color: var(--primary);
155
+
156
+ &:first-child {
157
+ padding-top: 14px;
158
+ border-top-right-radius: $borderRadius;
159
+ }
160
+
161
+ &:last-child {
162
+ padding-bottom: 14px;
163
+ border-bottom-right-radius: $borderRadius;
164
+ }
165
+ }
166
+ }
167
+
168
+ > div {
144
169
  overflow: hidden;
145
- @include transition(color, 200ms);
146
170
 
147
- &:hover {
171
+ label {
172
+ @include transition(color, 200ms);
173
+ }
174
+
175
+ &:hover > label {
148
176
  color: var(--contrast);
149
177
  }
150
178
  }
@@ -152,6 +180,42 @@ hotbar {
152
180
  &::-webkit-scrollbar-track {
153
181
  margin: 10px;
154
182
  }
183
+
184
+ div.favorite-submodule {
185
+ @include block();
186
+ @include transition(left, 300ms, (cubic-bezier(1, 0.35, 0, 1)));
187
+
188
+ padding: 14px 10px;
189
+ overflow: hidden;
190
+ white-space: nowrap;
191
+ left: -100vw;
192
+ position: absolute;
193
+ width: max-content;
194
+ display: flex;
195
+ flex-direction: column;
196
+ gap: 15px;
197
+ border-radius: $borderRadius;
198
+ pointer-events: none;
199
+ z-index: -2;
200
+ }
201
+
202
+ div.force-open-favorite-group div.favorite-submodule,
203
+ &:not(.has-forced-hover) > div:hover div.favorite-submodule {
204
+ @include transition(left, 300ms, (cubic-bezier(0, 1, 0.5, 1)), 100ms);
205
+
206
+ left: 100%;
207
+ pointer-events: all;
208
+
209
+ & > div:hover > label {
210
+ color: var(--contrast);
211
+ }
212
+ }
213
+
214
+ div.force-open-favorite-group {
215
+ > label {
216
+ color: var(--contrast);
217
+ }
218
+ }
155
219
  }
156
220
 
157
221
  &:not([main]) {
@@ -17,6 +17,7 @@ class HotbarController {
17
17
  public forceHide: boolean
18
18
  public ngifHide: boolean
19
19
  public openedIndexSub?: number = undefined
20
+ public openedFavoriteGroupIndex?: number = undefined
20
21
 
21
22
  constructor(
22
23
  public $element: JQuery,
@@ -64,6 +65,8 @@ class HotbarController {
64
65
  private __onClick: (ev: MouseEvent)=> void = (ev: MouseEvent): void => {
65
66
  if (this.sgElement.find(ev.target).length == 0 && this.openedIndexSub != undefined) {
66
67
  this.openedIndexSub = undefined
68
+ this.openedFavoriteGroupIndex = undefined
69
+
67
70
  try{
68
71
  this.$scope.$digest()
69
72
  }catch{}
@@ -87,11 +90,20 @@ class HotbarController {
87
90
  }
88
91
  }
89
92
 
90
- public getSubModuleStyle($index: number): CssInterface {
91
- const subModule = $(this.$element.find(`#sg-hotbar-sub-modules-${$index}`)[0])
93
+ public getSubModuleStyle($moduleIndex: number): CssInterface {
94
+ const id: string = `#sg-hotbar-sub-modules-${$moduleIndex}`;
95
+ const subModule = $(this.$element.find(id)[0]) as HTMLElement;
96
+
92
97
  return this.getSubModuleStyleFromElement(subModule);
93
98
  }
94
99
 
100
+ public getFavoriteSubmodulesStyle(subModuleIndex: number): CssInterface {
101
+ const id: string = `#sg-hotbar-favorite-submodules-${subModuleIndex}`;
102
+ const submodules = $(this.$element.find(id)[0]) as HTMLElement;
103
+
104
+ return this.getSubModuleStyleFromElement(submodules);
105
+ }
106
+
95
107
  private getSubModuleStyleFromElement(subModule: any): CssInterface {
96
108
  const borderRadius = 10;
97
109
  const hotbarHeight: number = this.sgElement.height() - (borderRadius * 4);
@@ -121,6 +133,7 @@ class HotbarController {
121
133
  cssObj.top = `${scrollTopPosition * -1 + borderRadius}px`;
122
134
  cssObj.bottom = '';
123
135
  }
136
+
124
137
  return cssObj;
125
138
  }
126
139
 
@@ -182,7 +195,12 @@ class HotbarController {
182
195
  }
183
196
 
184
197
  public onClickModule(index: number): void {
198
+ if (this.openedIndexSub !== index) {
199
+ this.openedFavoriteGroupIndex = undefined
200
+ }
201
+
185
202
  this.openedIndexSub = index
203
+
186
204
  try{
187
205
  this.$scope.$digest()
188
206
  }catch{}
@@ -217,6 +235,8 @@ class HotbarController {
217
235
  event.stopPropagation()
218
236
  event.preventDefault()
219
237
  this.openedIndexSub = undefined
238
+ this.openedFavoriteGroupIndex = undefined
239
+
220
240
  let access: boolean = true
221
241
  document.body.focus()
222
242
  if (subModuleConfig && !!subModuleConfig.key && (this.config.keys || []).indexOf(subModuleConfig.key) === -1) {
@@ -225,7 +245,6 @@ class HotbarController {
225
245
  }
226
246
  }
227
247
  if (access) {
228
- this.openedIndexSub = undefined
229
248
  switch (subModuleConfig.actionType) {
230
249
  case 'state':
231
250
  if (typeof subModuleConfig.action == 'string') {
@@ -260,6 +279,19 @@ class HotbarController {
260
279
  this.reloadComponent()
261
280
  }
262
281
  }
282
+
283
+ public goToFavoritesConfig(): void {
284
+ this.$state.go('app.favorites-config')
285
+ }
286
+
287
+ public onFavoriteGroupSelected(index: number): void {
288
+ if (this.openedFavoriteGroupIndex === index) {
289
+ this.openedFavoriteGroupIndex = undefined
290
+ return
291
+ }
292
+
293
+ this.openedFavoriteGroupIndex = index
294
+ }
263
295
  }
264
296
 
265
297
  const hotbar = {
@@ -1,23 +1,34 @@
1
+ import { Config } from "../components/hotbar/interface/config";
1
2
  import { $Scope, $Timeout } from "./../components/hotbar/interface/angular-interface/angular";
2
3
  import { MbSidemenuService } from "./../services/sidemenu-service";
3
4
 
4
5
  class SideMenuController {
5
6
  public menuOpen: boolean = false
6
7
  private watchConfig: Function
8
+ private unWatchRootConfig: Function
7
9
 
8
10
  constructor(
9
11
  public $timeout: $Timeout,
10
12
  public $scope: $Scope,
13
+ public $rootScope: $Scope,
11
14
  public mbSidemenuService: MbSidemenuService,
12
15
  ) { }
13
16
 
14
17
  $onInit(): void {
15
18
  this.$scope.$on('$destroy', (): void => this.$onDestroy())
16
- this.watchConfig = this.$scope.$watch('vm.config', (config: any): void => {
19
+
20
+ this.watchConfig = this.$scope.$watch('vm.config', (config: Config): void => {
17
21
  this.mbSidemenuService.setMenuConfig(config);
18
22
  this.$scope.structure = config ? config.structure : null;
19
23
  this.$scope.quickMenu = config ? config.quickMenu : null;
20
24
  })
25
+
26
+ this.unWatchRootConfig = this.$rootScope.$on('onChangeFavoritesConfig', (event: Event, config: Config): void => {
27
+ if (this.$scope.vm) {
28
+ this.$scope.vm.config = config
29
+ }
30
+ })
31
+
21
32
  this.mbSidemenuService.addCallback((value: boolean): any => {
22
33
  this.menuOpen = value
23
34
  })
@@ -25,6 +36,7 @@ class SideMenuController {
25
36
 
26
37
  $onDestroy(): void {
27
38
  this.__unWatch(this.watchConfig)
39
+ this.__unWatch(this.unWatchRootConfig)
28
40
  }
29
41
 
30
42
  private __unWatch(watch: Function): void {