-
Notifications
You must be signed in to change notification settings - Fork 108
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for defining global form attributes so you can define them once and reuse them all over.
- Loading branch information
Showing
5 changed files
with
106 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
apps/dashboard/app/lib/smart_attributes/attributes/global_attribute.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# frozen_string_literal: true | ||
|
||
module SmartAttributes | ||
class AttributeFactory | ||
# Build this attribute object with defined options | ||
# @param opts [Hash] attribute's options | ||
# @return [Attributes::GlobalAttribute] the attribute object | ||
def self.build_global_attribute(opts = {}) | ||
id = opts.delete('key').to_s | ||
|
||
config = Configuration.global_bc_form_item(id) | ||
|
||
# this behaves like a normal Attribute if there's no actual configuration for it. | ||
config = opts if config.nil? || config.empty? | ||
Attributes::GlobalAttribute.new(id, config) | ||
end | ||
end | ||
|
||
module Attributes | ||
class GlobalAttribute < Attribute | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters