-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refine Integration #710
Draft
kaspth
wants to merge
19
commits into
main
Choose a base branch
from
refine-integration
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Refine Integration #710
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
5d4fcb2
Start committing refine integration
kaspth 8b997dd
Remove Refine::Filter methods
kaspth ff55a67
Commit _index with filter without all the CSS I still haven't rooted …
kaspth 22bdc00
Let Refine popup spill out of box
kaspth bdf9133
Improve design a bit
kaspth 9aec136
Import Refine's CSS manually in light theme for now
kaspth e9eb7fd
Rename our refine support controller
kaspth 382ef94
Use column null: false info to automatically reject presence clauses
kaspth 2f33965
Fix standardrb
kaspth 98ed02d
Remove unneeded model
kaspth 84fa4aa
Remove unused methods for now
kaspth 83eae27
Use gem released version
kaspth 8a19ad3
We can move the dependency to the gemspec now
kaspth 7d29a96
Merge branch 'main' into refine-integration
kaspth ad82d6b
Update other Gemfile.locks with new dependency
kaspth 99e6211
See if an explicit require will fix it
kaspth eecfd5d
Move the require to here?
kaspth 6544c58
oops wrong naming format
kaspth 1d0f05e
Refactor i18n_scope a bit
kaspth File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
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
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
3 changes: 3 additions & 0 deletions
3
...ing/app/controllers/account/scaffolding/completely_concrete/tangible_things_controller.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
55 changes: 55 additions & 0 deletions
55
bullet_train-super_scaffolding/app/models/application_filter.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,55 @@ | ||
class ApplicationFilter < Refine::Filter | ||
include Refine::Conditions | ||
|
||
class_attribute :i18n_scope, instance_writer: false | ||
|
||
def self.inherited(klass) | ||
klass.i18n_scope = klass.name.sub(/(::)?Filter$/, "").pluralize.underscore.tr("/", ".") | ||
super | ||
end | ||
|
||
CONDITIONS = { | ||
option: OptionCondition, | ||
numeric: NumericCondition, | ||
text: TextCondition, | ||
boolean: BooleanCondition, | ||
date: DateCondition, | ||
datetime: DateWithTimeCondition, | ||
} | ||
|
||
# list conditions in alphabetical order | ||
def conditions_to_array | ||
super&.sort_by { _1[:display].to_s.downcase } | ||
end | ||
|
||
private | ||
|
||
def condition(field, type) | ||
condition = CONDITIONS.fetch(type).new(field.to_s).with_display(heading(field)) | ||
|
||
# Reject set/not_set clause options in case the field can't be null in the database. | ||
if (column = column_for(field)) | ||
condition = condition.without_clauses([Clauses::SET, Clauses::NOT_SET]) if column.null == false | ||
end | ||
|
||
# Derive options via I18n scope. | ||
condition = condition.with_options(options_for(field)) if type == :option | ||
condition | ||
end | ||
|
||
def column_for(field) | ||
model.connection.columns(model.table_name).index_by(&:name)[field.to_s] | ||
end | ||
|
||
def heading(field) | ||
t("#{field}.heading") | ||
end | ||
|
||
def options_for(field) | ||
t("#{field}.options").map { {id: _1.to_s, display: _2} } | ||
end | ||
|
||
def t(key, **) | ||
I18n.t("#{i18n_scope}.fields.#{key}", **) | ||
end | ||
end |
34 changes: 34 additions & 0 deletions
34
...ain-super_scaffolding/app/models/scaffolding/completely_concrete/tangible_thing/filter.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,34 @@ | ||
class Scaffolding::CompletelyConcrete::TangibleThing::Filter < ApplicationFilter | ||
self.i18n_scope = "account.#{i18n_scope}" | ||
|
||
def conditions | ||
[ | ||
condition(:text_field_value, :text), | ||
condition(:email_field_value, :text), | ||
condition(:phone_field_value, :text), | ||
condition(:address_value, :text), | ||
condition(:text_area_value, :text), | ||
condition(:action_text_value, :text), | ||
|
||
condition(:sort_order, :numeric), | ||
|
||
condition(:color_picker_value, :option), | ||
condition(:button_value, :option), | ||
condition(:boolean_button_value, :option), | ||
condition(:multiple_button_values, :option), | ||
condition(:option_value, :option), | ||
condition(:multiple_option_values, :option), | ||
condition(:super_select_value, :option), | ||
condition(:multiple_super_select_values, :option), | ||
|
||
condition(:date_field_value, :date), | ||
condition(:date_and_time_field_value, :datetime), | ||
condition(:created_at, :datetime), | ||
condition(:updated_at, :datetime), | ||
] | ||
end | ||
|
||
def model | ||
self.class.module_parent | ||
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
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
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One thing I would recommend is we add in the clause manipulations for created_at and updated_at generators. The IS_SET and IS_NOT_SET clauses serve no purpose for these fields since they are always present so the scaffolding should probably automatically apply
.without_clauses([DateWithTimeCondition::CLAUSE_SET, DateWithTimeCondition::CLAUSE_NOT_SET])
for simplicityThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ssteffen good point! I just pushed 382ef94 which will use a column's
null: false
information to automatically reject the presence concerned clauses aka SET/NOT_SET.I think I found a bug in Refine though, so I'll submit a PR shortly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope, looks like that was fixed in clickfunnels2/refine-rails#157, but I happened to be running an older version of Refine (thought I'd updated ugh).