caixanegra 0.1.2 → 0.2.0

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
  SHA256:
3
- metadata.gz: df3d38ccee4981c27d6acb8e72bc4c40c00537c6c370cdc17581de1dc179ac3f
4
- data.tar.gz: 4bad76dfbfb9834d19389a28f92a7b3a7a1208c9cdf230a43fc4f9faf6322fb4
3
+ metadata.gz: c291dfc1c33d2c17e87093eff1bceff3c061ef8c7230a561ace088cd9e23f279
4
+ data.tar.gz: e812c3f4c1d202902f926115162c0b9b46885b35af56db52db3aa94ab8e53ac8
5
5
  SHA512:
6
- metadata.gz: 464c5ebbc06fa24c1f6f9261dd9e4241dff7bbfc8ccca0f067de5f289e5bda3a4e658475c8b15fa72971574748927016e5e23eed6020a0eda94580e7e85128ed
7
- data.tar.gz: 55fcf0df7d3aac4d6e4458728cab6f3cfe874014903d47b5e4de1976290d8728cccdd28a687a748e43b5338bb6090b94596bb56fb43437ebbf203934c525717a
6
+ metadata.gz: c6276bd14d36c832729b8a717a15ad5a8c6b9e6223343d6169fa1c153dc0389d0d0ef73ed61b0eb4f19a9dfc1936683b59b80e994b740df4cc670958fbc21833
7
+ data.tar.gz: 70059940599beff0f5cf09bbb73defa53fc31e336166a15a0262902f194862cd318b5bb8fb7bcb22a7934960411c7dce14f997816a0430fc943ba6d0dceddb88
@@ -522,33 +522,63 @@ window.Caixanegra.Designer = {
522
522
  this.#catalog = response;
523
523
  const unitMenu = document.querySelector("#unitMenu");
524
524
  unitMenu.innerHTML = "";
525
- this.#catalog.forEach((unitData) => {
526
- const item = document.createElement("div");
527
- const content = document.createElement("div");
528
- const colorCode = document.createElement("div");
529
- const header = document.createElement("div");
530
- const name = document.createElement("span");
531
- const type = document.createElement("span");
532
- const description = document.createElement("div");
533
- description.classList.add("description");
534
- item.classList.add("unit");
535
- header.classList.add("header");
536
- content.classList.add("content");
537
- colorCode.classList.add("color-code");
538
- name.classList.add("name");
539
- type.classList.add("type");
540
-
541
- name.innerHTML = unitData.title;
542
- type.innerHTML = unitData.type;
543
- description.innerHTML = unitData.description;
544
- colorCode.style.backgroundColor = Caixanegra.Designer.typeColor(unitData.type);
545
-
546
- header.append(name, type);
547
- content.append(header, description);
548
- item.append(colorCode, content);
549
- item.addEventListener("click", this.createUnit.bind(this, unitData));
550
- unitMenu.appendChild(item);
525
+
526
+ const scopes = [];
527
+
528
+ this.#catalog.forEach(unit => {
529
+ if (unit.hasOwnProperty("scope") && Array.isArray(unit.scope)) {
530
+ scopes.push(...unit.scope);
531
+ } else {
532
+ scopes.push("_unscoped");
533
+ }
534
+ });
535
+
536
+ [...new Set(scopes)].sort().forEach(scope => {
537
+ const scopeWrapper = document.createElement("div");
538
+ const scopeTitle = document.createElement("div");
539
+ const scopeUnits = document.createElement("div");
540
+
541
+ scopeWrapper.classList.add("unit-wrapper");
542
+ scopeTitle.classList.add("title");
543
+
544
+ scopeTitle.innerHTML = scope === "_unscoped" ? "unscoped" : scope.replace(/_/g, " ");
545
+ scopeWrapper.appendChild(scopeTitle);
546
+ scopeWrapper.appendChild(scopeUnits);
547
+
548
+ const filteredUnits = this.#catalog.filter(unit => {
549
+ return (unit.scope === null && scope === "_unscoped") || (unit.scope || []).includes(scope)
550
+ });
551
+
552
+ filteredUnits.forEach((unitData) => {
553
+ const item = document.createElement("div");
554
+ const content = document.createElement("div");
555
+ const colorCode = document.createElement("div");
556
+ const header = document.createElement("div");
557
+ const name = document.createElement("span");
558
+ const type = document.createElement("span");
559
+ const description = document.createElement("div");
560
+ description.classList.add("description");
561
+ item.classList.add("unit");
562
+ header.classList.add("header");
563
+ content.classList.add("content");
564
+ colorCode.classList.add("color-code");
565
+ name.classList.add("name");
566
+ type.classList.add("type");
567
+
568
+ name.innerHTML = unitData.title;
569
+ type.innerHTML = unitData.type;
570
+ description.innerHTML = unitData.description;
571
+ colorCode.style.backgroundColor = Caixanegra.Designer.typeColor(unitData.type);
572
+
573
+ header.append(name, type);
574
+ content.append(header, description);
575
+ item.append(colorCode, content);
576
+ item.addEventListener("click", this.createUnit.bind(this, unitData));
577
+ scopeUnits.appendChild(item);
578
+ });
579
+ unitMenu.appendChild(scopeWrapper);
551
580
  });
581
+
552
582
  this.#loadedComponents.catalog = true;
553
583
  this.#reveal();
554
584
  });
@@ -119,6 +119,15 @@ $accent-contrast-color: darken($accent-color, 20%);
119
119
  transform: translateY(0%);
120
120
  }
121
121
 
122
+ .unit-wrapper {
123
+ .title {
124
+ font-family: Verdana, Geneva, Tahoma, sans-serif;
125
+ font-size: 0.7em;
126
+ color: rgba(0,0,0,.7);
127
+ margin-bottom: 5px;
128
+ }
129
+ }
130
+
122
131
  .unit {
123
132
  display: flex;
124
133
  flex-direction: row;
@@ -17,7 +17,8 @@ module Caixanegra
17
17
  def units
18
18
  @units ||= ::Caixanegra::UnitHelper.scoped_units(unit_scope).map do |k, v|
19
19
  base = {
20
- title: v.name,
20
+ scope: v.scope,
21
+ title: v.unit_name,
21
22
  type: v.type,
22
23
  description: v.description,
23
24
  class: k,
@@ -76,8 +76,12 @@ module Caixanegra
76
76
  raise(UnitIOException.new, "Unable to fetch input '#{id}'")
77
77
  end
78
78
 
79
- def name
80
- self.class.name
79
+ def scope
80
+ self.class.scope
81
+ end
82
+
83
+ def unit_name
84
+ self.class.unit_name
81
85
  end
82
86
 
83
87
  def description
@@ -108,12 +112,16 @@ module Caixanegra
108
112
  end
109
113
 
110
114
  class << self
111
- attr_reader :name, :description, :inputs, :exits, :assignments, :type
115
+ attr_reader :unit_name, :description, :inputs, :exits, :assignments, :type, :scope
112
116
 
113
117
  @type = :passthrough
114
118
 
119
+ def configure_scope(value)
120
+ @scope = value
121
+ end
122
+
115
123
  def configure_name(value)
116
- @name = value
124
+ @unit_name = value
117
125
  end
118
126
 
119
127
  def configure_description(value)
@@ -148,9 +148,11 @@ module Caixanegra
148
148
 
149
149
  exit_name = result[:exit_through]
150
150
  metadata = unit_metadata(@step_unit.oid)
151
- log_console_entry "Next unit found through '#{exit_name}': '#{@step_unit.oid}'"
152
151
  exit_metadata = metadata[:exits].find { |ex| ex[:name] == exit_name.to_s }
153
- unit(exit_metadata[:target], map_carry_over(result))
152
+ next_unit = unit(exit_metadata[:target], map_carry_over(result))
153
+ log_console_entry "Next unit found through '#{exit_name}': '#{next_unit.oid}'"
154
+
155
+ next_unit
154
156
  end
155
157
 
156
158
  def process_feeders
@@ -2,30 +2,26 @@ module Caixanegra
2
2
  class UnitHelper
3
3
  class << self
4
4
  def scoped_units(scope)
5
- all_units = {}
6
- all_units = all_units.merge(Caixanegra.units.reject { |_, v| v.is_a? Hash })
5
+ units = {}
7
6
 
8
- (scope || "").split(",").each do |current_scope|
9
- all_units = all_units.merge(Caixanegra.units[current_scope.to_sym])
7
+ scopes = (scope || "").split(",").map(&:to_sym)
8
+ Caixanegra.units.each do |unit|
9
+ if unit.scope.nil? || unit.scope.any? { |checking_scope| scopes.include?(checking_scope) }
10
+ units[unit.name.demodulize.underscore.to_sym] = unit
11
+ end
10
12
  end
11
13
 
12
- all_units
14
+ units
13
15
  end
14
16
 
15
17
  def all_units
16
- all_units = {}
18
+ units = {}
17
19
 
18
- Caixanegra.units.each do |k, v|
19
- if v.is_a? Hash
20
- v.each do |ik, iv|
21
- all_units[ik] = iv
22
- end
23
- else
24
- all_units[k] = v
25
- end
20
+ Caixanegra.units.each do |unit|
21
+ units[unit.name.demodulize.underscore.to_sym] = unit
26
22
  end
27
23
 
28
- all_units
24
+ units
29
25
  end
30
26
  end
31
27
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Caixanegra
4
- VERSION = '0.1.2'
4
+ VERSION = '0.2.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: caixanegra
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - sergiorribeiro
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-06-14 00:00:00.000000000 Z
11
+ date: 2023-06-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -61,7 +61,6 @@ files:
61
61
  - app/controllers/caixanegra/api_controller.rb
62
62
  - app/controllers/caixanegra/application_controller.rb
63
63
  - app/controllers/caixanegra/designer_controller.rb
64
- - app/helpers/caixanegra/application_helper.rb
65
64
  - app/models/caixanegra/unit.rb
66
65
  - app/views/caixanegra/designer/index.html.erb
67
66
  - app/views/layouts/caixanegra/application.html.erb
@@ -1,4 +0,0 @@
1
- module Caixanegra
2
- module ApplicationHelper
3
- end
4
- end