source
stringclasses
1 value
repo
stringlengths
5
63
repo_url
stringlengths
24
82
path
stringlengths
5
167
language
stringclasses
1 value
license
stringclasses
5 values
stars
int64
10
51.4k
ref
stringclasses
23 values
size_bytes
int64
200
258k
text
stringlengths
137
258k
github
rails-engine/form_core
https://github.com/rails-engine/form_core
lib/form_core/errors.rb
Ruby
mit
188
master
214
# frozen_string_literal: true module FormCore # = Form Core Errors # # Generic Form Core exception class. class FormCoreError < StandardError end class DecodingDataCorrupted < FormCoreError end end
github
rails-engine/form_core
https://github.com/rails-engine/form_core
lib/form_core/coder.rb
Ruby
mit
188
master
748
# frozen_string_literal: true module FormCore class Coder cattr_accessor :strict attr_reader :object_class def initialize(object_class) @object_class = object_class end def strict? Coder.strict end def dump(_obj) raise NotImplementedError end def load(_src) ...
github
rails-engine/form_core
https://github.com/rails-engine/form_core
lib/form_core/virtual_model.rb
Ruby
mit
188
master
2,103
# frozen_string_literal: true require "active_entity" module FormCore class VirtualModel < ::ActiveEntity::Base # Returns the contents of the record as a nicely formatted string. def inspect # We check defined?(@attributes) not to issue warnings if the object is # allocated but not initialized. ...
github
rails-engine/form_core
https://github.com/rails-engine/form_core
lib/form_core/coders/hash_coder.rb
Ruby
mit
188
master
337
# frozen_string_literal: true require "yaml" module FormCore class HashCoder < FormCore::Coder # :nodoc: def dump(obj) obj&.serializable_hash || {} end def load(hash) return new_or_raise_decoding_error if hash.nil? || !hash.respond_to?(:to_h) object_class.new valid_attributes(hash) ...
github
rails-engine/form_core
https://github.com/rails-engine/form_core
lib/form_core/coders/yaml_coder.rb
Ruby
mit
188
master
815
# frozen_string_literal: true require "yaml" module FormCore class YAMLCoder < FormCore::Coder # :nodoc: cattr_accessor :safe_mode def self.whitelist_classes @whitelist_classes ||= [] end def safe_mode? YAMLCoder.safe_mode end def dump(obj) return YAML.dump({}) unless ob...
github
rails-engine/form_core
https://github.com/rails-engine/form_core
lib/form_core/concerns/models/form.rb
Ruby
mit
188
master
1,147
# frozen_string_literal: true module FormCore::Concerns module Models module Form extend ActiveSupport::Concern def to_virtual_model(model_name: "Form", fields_scope: proc { |fields| fields }, overrides: {}) model = FormCore.virtual_model...
github
rails-engine/form_core
https://github.com/rails-engine/form_core
lib/form_core/concerns/models/field.rb
Ruby
mit
188
master
2,403
# frozen_string_literal: true module FormCore::Concerns module Models module Field extend ActiveSupport::Concern NAME_REGEX = /\A[a-z][a-z_0-9]*\z/.freeze included do enum accessibility: { read_and_write: 0, readonly: 1, hidden: 2 }, _prefix: :access serialize :v...
github
rails-engine/form_core
https://github.com/rails-engine/form_core
test/dummy/lib/monkey_patches/active_support/concern+prependable.rb
Ruby
mit
188
master
810
# frozen_string_literal: true # Cheated from https://gitlab.com/gitlab-org/gitlab-ee/blob/master/config/initializers/0_as_concern.rb # This module is based on: https://gist.github.com/bcardarella/5735987 module Prependable def prepend_features(base) if base.instance_variable_defined?(:@_dependencies) base...
github
rails-engine/form_core
https://github.com/rails-engine/form_core
test/dummy/app/helpers/forms_helper.rb
Ruby
mit
188
master
267
# frozen_string_literal: true module FormsHelper def smart_form_fields_path(form) case form when Form form_fields_path(form) when NestedForm nested_form_fields_path(form) else raise "Unknown form: #{form.class}" end end end
github
rails-engine/form_core
https://github.com/rails-engine/form_core
test/dummy/app/helpers/application_helper.rb
Ruby
mit
188
master
548
# frozen_string_literal: true module ApplicationHelper def options_for_enum_select(klass, attribute, selected = nil) container = klass.public_send(attribute.to_s.pluralize).map do |k, v| v ||= k [klass.human_enum_value(attribute, k), v] end options_for_select(container, selected) end de...
github
rails-engine/form_core
https://github.com/rails-engine/form_core
test/dummy/app/helpers/fields_helper.rb
Ruby
mit
188
master
788
# frozen_string_literal: true module FieldsHelper def options_for_field_types(selected: nil) options_for_select(Field.descendants.map { |klass| [klass.model_name.human, klass.to_s] }, selected) end def options_for_data_source_types(selected: nil) options_for_select(DataSource.descendants.map { |klass| [...
github
rails-engine/form_core
https://github.com/rails-engine/form_core
test/dummy/app/controllers/dictionaries_controller.rb
Ruby
mit
188
master
1,353
# frozen_string_literal: true class DictionariesController < ApplicationController before_action :set_dictionary, only: %i[edit update destroy] # GET /dictionaries/dictionaries def index @dictionaries = Dictionary.all end # GET /dictionaries/dictionaries/new def new @dictionary = Dictionary.new ...
github
rails-engine/form_core
https://github.com/rails-engine/form_core
test/dummy/app/controllers/forms_controller.rb
Ruby
mit
188
master
1,281
# frozen_string_literal: true class FormsController < ApplicationController layout "application" before_action :set_form, only: %i[edit update destroy] # GET /forms def index @forms = Form.all end # GET /forms/new def new @form = Form.new end # GET /forms/1/edit def edit; end # POST ...
github
rails-engine/form_core
https://github.com/rails-engine/form_core
test/dummy/app/controllers/time_zones_controller.rb
Ruby
mit
188
master
313
# frozen_string_literal: true class TimeZonesController < ApplicationController def update @time_zone = ActiveSupport::TimeZone[params[:time_zone]] return render :not_found unless @time_zone session[:current_time_zone] = params[:time_zone] redirect_back fallback_location: root_url end end
github
rails-engine/form_core
https://github.com/rails-engine/form_core
test/dummy/app/controllers/application_controller.rb
Ruby
mit
188
master
528
# frozen_string_literal: true class ApplicationController < ActionController::Base around_action :set_time_zone helper_method :current_time_zone private def set_time_zone(&block) Time.use_zone(current_time_zone, &block) end def current_time_zone @_current_time_zone ||= if sess...
github
rails-engine/form_core
https://github.com/rails-engine/form_core
test/dummy/app/controllers/nested_forms/fields_controller.rb
Ruby
mit
188
master
1,210
# frozen_string_literal: true class NestedForms::FieldsController < NestedForms::ApplicationController before_action :set_field, only: %i[show edit update destroy] def index @fields = @nested_form.fields.includes(:section).all end def new @field = @nested_form.fields.build end def edit; end d...
github
rails-engine/form_core
https://github.com/rails-engine/form_core
test/dummy/app/controllers/nested_forms/application_controller.rb
Ruby
mit
188
master
315
# frozen_string_literal: true class NestedForms::ApplicationController < ApplicationController before_action :set_nested_form protected # Use callbacks to share common setup or constraints between actions. def set_nested_form @nested_form = NestedForm.find(params[:nested_form_id]) end end
github
rails-engine/form_core
https://github.com/rails-engine/form_core
test/dummy/app/controllers/fields/validations_controller.rb
Ruby
mit
188
master
560
# frozen_string_literal: true class Fields::ValidationsController < Fields::ApplicationController before_action :set_validations def edit; end def update @validations.assign_attributes(validations_params) if @validations.valid? && @field.save(validate: false) redirect_to fields_url, notice: "Fiel...
github
rails-engine/form_core
https://github.com/rails-engine/form_core
test/dummy/app/controllers/fields/options_controller.rb
Ruby
mit
188
master
520
# frozen_string_literal: true class Fields::OptionsController < Fields::ApplicationController before_action :set_options def edit; end def update @options.assign_attributes(options_params) if @options.valid? && @field.save(validate: false) redirect_to fields_url, notice: "Field was successfully u...
github
rails-engine/form_core
https://github.com/rails-engine/form_core
test/dummy/app/controllers/fields/data_source_options_controller.rb
Ruby
mit
188
master
693
# frozen_string_literal: true class Fields::DataSourceOptionsController < Fields::ApplicationController before_action :require_data_source_options before_action :set_options def edit; end def update @options.assign_attributes(options_params) if @options.valid? && @field.save(validate: false) re...
github
rails-engine/form_core
https://github.com/rails-engine/form_core
test/dummy/app/controllers/fields/choices_controller.rb
Ruby
mit
188
master
921
# frozen_string_literal: true class Fields::ChoicesController < Fields::ApplicationController before_action :require_attach_choices! before_action :set_choice, only: %i[edit update destroy] def new @choice = @field.choices.build end def create @choice = @field.choices.build choice_params if @ch...
github
rails-engine/form_core
https://github.com/rails-engine/form_core
test/dummy/app/controllers/fields/application_controller.rb
Ruby
mit
188
master
521
# frozen_string_literal: true class Fields::ApplicationController < ApplicationController before_action :set_field protected # Use callbacks to share common setup or constraints between actions. def set_field @field = Field.find(params[:field_id]) end def fields_url form = @field.for...
github
rails-engine/form_core
https://github.com/rails-engine/form_core
test/dummy/app/controllers/forms/application_controller.rb
Ruby
mit
188
master
739
# frozen_string_literal: true class Forms::ApplicationController < ApplicationController layout "forms" before_action :set_form protected # Use callbacks to share common setup or constraints between actions. def set_form @form = Form.find(params[:form_id]) end def set_form_with_eager_lo...
github
rails-engine/form_core
https://github.com/rails-engine/form_core
test/dummy/app/controllers/forms/previews_controller.rb
Ruby
mit
188
master
566
# frozen_string_literal: true class Forms::PreviewsController < Forms::ApplicationController skip_before_action :set_form before_action :set_form_with_eager_load_fields_and_sections before_action :set_preview def show @instance = @preview.new end def create @instance = @preview.new(preview_params...
github
rails-engine/form_core
https://github.com/rails-engine/form_core
test/dummy/app/controllers/forms/sections_controller.rb
Ruby
mit
188
master
1,310
# frozen_string_literal: true class Forms::SectionsController < Forms::ApplicationController before_action :set_section, only: %i[show edit update destroy] # GET /forms/1/sections def index @sections = @form.sections.all end # GET /forms/sections/new def new @section = @form.sections.build end ...
github
rails-engine/form_core
https://github.com/rails-engine/form_core
test/dummy/app/controllers/forms/loads_controller.rb
Ruby
mit
188
master
530
# frozen_string_literal: true class Forms::LoadsController < Forms::ApplicationController skip_before_action :set_form, except: [:show] before_action :set_form_with_eager_load_fields_and_sections, except: [:show] before_action :set_preview, except: [:show] def show; end def create @instance = @preview....
github
rails-engine/form_core
https://github.com/rails-engine/form_core
test/dummy/app/controllers/forms/fields_controller.rb
Ruby
mit
188
master
1,308
# frozen_string_literal: true class Forms::FieldsController < Forms::ApplicationController before_action :set_field, only: %i[show edit update destroy] # GET /forms/1/fields def index @fields = @form.fields.includes(:section).all end # GET /forms/fields/new def new @field = @form.fields.build e...
github
rails-engine/form_core
https://github.com/rails-engine/form_core
test/dummy/app/models/dictionary.rb
Ruby
mit
188
master
337
# frozen_string_literal: true class Dictionary < ApplicationRecord SCOPE_REGEX = /\A([a-z_][a-z_0-9]*\.)*[a-z_][a-z_0-9]*\z/.freeze attribute :value, :string validates :value, presence: true, uniqueness: { scope: :scope } validates :scope, presence: true, format: { with: S...
github
rails-engine/form_core
https://github.com/rails-engine/form_core
test/dummy/app/models/form.rb
Ruby
mit
188
master
358
# frozen_string_literal: true class Form < MetalForm has_many :sections, -> { order(position: :asc) }, dependent: :destroy validates :title, presence: true after_create :auto_create_default_section private def auto_create_default_section sections.create! title: I18n.t("defaults.sectio...
github
rails-engine/form_core
https://github.com/rails-engine/form_core
test/dummy/app/models/data_source.rb
Ruby
mit
188
master
937
# frozen_string_literal: true class DataSource < FieldOptions def type_key self.class.type_key end def stored_type :integer end def foreign_field_name_suffix "_id" end def foreign_field_name(field_name) "#{field_name}#{foreign_field_name_suffix}" end def value_method :id end...
github
rails-engine/form_core
https://github.com/rails-engine/form_core
test/dummy/app/models/section.rb
Ruby
mit
188
master
254
# frozen_string_literal: true class Section < ApplicationRecord belongs_to :form, touch: true has_many :fields, -> { order(position: :asc) }, dependent: :nullify acts_as_list scope: [:form_id] validates :title, presence: true end
github
rails-engine/form_core
https://github.com/rails-engine/form_core
test/dummy/app/models/field.rb
Ruby
mit
188
master
1,791
# frozen_string_literal: true class Field < ApplicationRecord include FormCore::Concerns::Models::Field self.table_name = "fields" belongs_to :form, class_name: "MetalForm", foreign_key: "form_id", touch: true belongs_to :section, touch: true, optional: true # Only use for specific fields has_many :cho...
github
rails-engine/form_core
https://github.com/rails-engine/form_core
test/dummy/app/models/fields.rb
Ruby
mit
188
master
507
# frozen_string_literal: true module Fields %w[ text boolean decimal integer date datetime choice multiple_choice select multiple_select integer_range decimal_range date_range datetime_range nested_form multiple_nested_form attachment multiple_attachment resource_select multiple_resou...
github
rails-engine/form_core
https://github.com/rails-engine/form_core
test/dummy/app/models/metal_form.rb
Ruby
mit
188
master
231
# frozen_string_literal: true class MetalForm < ApplicationRecord include FormCore::Concerns::Models::Form self.table_name = "forms" has_many :fields, foreign_key: "form_id", dependent: :destroy include Forms::Fake end
github
rails-engine/form_core
https://github.com/rails-engine/form_core
test/dummy/app/models/field_options.rb
Ruby
mit
188
master
2,404
# frozen_string_literal: true class FieldOptions < ActiveEntity::Base include FormCore::ActsAsDefaultValue include EnumAttributeLocalizable # self.inheritance_column = nil class_attribute :keeping_old_serialization attr_accessor :raw_attributes def interpret_to(_model, _field_name, _accessibility, _opt...
github
rails-engine/form_core
https://github.com/rails-engine/form_core
test/dummy/app/models/virtual_model.rb
Ruby
mit
188
master
642
# frozen_string_literal: true class VirtualModel < FormCore::VirtualModel include FormCore::ActiveStorageBridge::Attached::Macros include FormCore::ActsAsDefaultValue include EnumAttributeLocalizable # self.inheritance_column = nil def persisted? false end class << self def nested_models ...
github
rails-engine/form_core
https://github.com/rails-engine/form_core
test/dummy/app/models/data_sources/dictionary.rb
Ruby
mit
188
master
511
# frozen_string_literal: true module DataSources class Dictionary < DataSource def text_method :value end def value_for_preview_method :value end attribute :scope, :string, default: "" validates :scope, format: { with: ::Dictionary::SCOPE_REGEX }, al...
github
rails-engine/form_core
https://github.com/rails-engine/form_core
test/dummy/app/models/data_sources/empty.rb
Ruby
mit
188
master
417
# frozen_string_literal: true module DataSources class Empty < DataSource def foreign_field_name_suffix "" end def foreign_field_name(field_name) field_name end def text_method nil end def interpret_to(_model, _field_name, _accessibility, _options = {}); end clas...
github
rails-engine/form_core
https://github.com/rails-engine/form_core
test/dummy/app/models/fields/resource_field.rb
Ruby
mit
188
master
649
# frozen_string_literal: true module Fields class ResourceField < Field serialize :options, Options::ResourceField serialize :validations, Validations::ResourceField def stored_type :integer end delegate :data_source, to: :options def collection data_source.scoped_records e...
github
rails-engine/form_core
https://github.com/rails-engine/form_core
test/dummy/app/models/fields/decimal_field.rb
Ruby
mit
188
master
228
# frozen_string_literal: true module Fields class DecimalField < Field serialize :validations, Validations::DecimalField serialize :options, Options::DecimalField def stored_type :decimal end end end
github
rails-engine/form_core
https://github.com/rails-engine/form_core
test/dummy/app/models/fields/datetime_range_field.rb
Ruby
mit
188
master
804
# frozen_string_literal: true module Fields class DatetimeRangeField < Field serialize :validations, Validations::DatetimeRangeField serialize :options, Options::DatetimeRangeField def interpret_to(model, overrides: {}) check_model_validity!(model) accessibility = overrides.fetch(:accessibi...
github
rails-engine/form_core
https://github.com/rails-engine/form_core
test/dummy/app/models/fields/nested_form_field.rb
Ruby
mit
188
master
1,000
# frozen_string_literal: true module Fields class NestedFormField < Field after_create do build_nested_form.save! end serialize :validations, Validations::NestedFormField serialize :options, NonConfigurable def attached_nested_form? true end def interpret_to(model, override...
github
rails-engine/form_core
https://github.com/rails-engine/form_core
test/dummy/app/models/fields/integer_range_field.rb
Ruby
mit
188
master
800
# frozen_string_literal: true module Fields class IntegerRangeField < Field serialize :validations, Validations::IntegerRangeField serialize :options, Options::IntegerRangeField def interpret_to(model, overrides: {}) check_model_validity!(model) accessibility = overrides.fetch(:accessibilit...
github
rails-engine/form_core
https://github.com/rails-engine/form_core
test/dummy/app/models/fields/boolean_field.rb
Ruby
mit
188
master
222
# frozen_string_literal: true module Fields class BooleanField < Field serialize :validations, Validations::BooleanField serialize :options, NonConfigurable def stored_type :boolean end end end
github
rails-engine/form_core
https://github.com/rails-engine/form_core
test/dummy/app/models/fields/decimal_range_field.rb
Ruby
mit
188
master
800
# frozen_string_literal: true module Fields class DecimalRangeField < Field serialize :validations, Validations::DecimalRangeField serialize :options, Options::DecimalRangeField def interpret_to(model, overrides: {}) check_model_validity!(model) accessibility = overrides.fetch(:accessibilit...
github
rails-engine/form_core
https://github.com/rails-engine/form_core
test/dummy/app/models/fields/multiple_choice_field.rb
Ruby
mit
188
master
1,079
# frozen_string_literal: true module Fields class MultipleChoiceField < Field serialize :validations, Validations::MultipleChoiceField serialize :options, NonConfigurable def stored_type :integer end def attached_choices? true end def interpret_to(model, overrides: {}) ...
github
rails-engine/form_core
https://github.com/rails-engine/form_core
test/dummy/app/models/fields/multiple_resource_field.rb
Ruby
mit
188
master
1,154
# frozen_string_literal: true module Fields class MultipleResourceField < Field serialize :validations, Validations::MultipleResourceField serialize :options, Options::MultipleResourceField def stored_type :string end delegate :data_source, to: :options def collection data_sour...
github
rails-engine/form_core
https://github.com/rails-engine/form_core
test/dummy/app/models/fields/datetime_field.rb
Ruby
mit
188
master
493
# frozen_string_literal: true module Fields class DatetimeField < Field serialize :validations, Validations::DatetimeField serialize :options, Options::DatetimeField def stored_type :datetime end protected def interpret_extra_to(model, accessibility, overrides = {}) super ...
github
rails-engine/form_core
https://github.com/rails-engine/form_core
test/dummy/app/models/fields/multiple_select_field.rb
Ruby
mit
188
master
1,051
# frozen_string_literal: true module Fields class MultipleSelectField < Field serialize :validations, Validations::MultipleSelectField serialize :options, Options::MultipleSelectField def stored_type :string end def attached_choices? true end def interpret_to(model, overrid...
github
rails-engine/form_core
https://github.com/rails-engine/form_core
test/dummy/app/models/fields/multiple_attachment_field.rb
Ruby
mit
188
master
764
# frozen_string_literal: true module Fields class MultipleAttachmentField < Field serialize :validations, Validations::MultipleAttachmentField serialize :options, NonConfigurable def stored_type :integer end def interpret_to(model, overrides: {}) check_model_validity!(model) ...
github
rails-engine/form_core
https://github.com/rails-engine/form_core
test/dummy/app/models/fields/integer_field.rb
Ruby
mit
188
master
460
# frozen_string_literal: true module Fields class IntegerField < Field serialize :validations, Validations::IntegerField serialize :options, Options::IntegerField def stored_type :integer end protected def interpret_extra_to(model, accessibility, _overrides = {}) return if ...
github
rails-engine/form_core
https://github.com/rails-engine/form_core
test/dummy/app/models/fields/multiple_resource_select_field.rb
Ruby
mit
188
master
1,198
# frozen_string_literal: true module Fields class MultipleResourceSelectField < Field serialize :validations, Validations::MultipleResourceSelectField serialize :options, Options::MultipleResourceSelectField def stored_type :string end delegate :data_source, to: :options def collecti...
github
rails-engine/form_core
https://github.com/rails-engine/form_core
test/dummy/app/models/fields/date_field.rb
Ruby
mit
188
master
481
# frozen_string_literal: true module Fields class DateField < Field serialize :validations, Validations::DateField serialize :options, Options::DateField def stored_type :datetime end protected def interpret_extra_to(model, accessibility, overrides = {}) super mode...
github
rails-engine/form_core
https://github.com/rails-engine/form_core
test/dummy/app/models/fields/choice_field.rb
Ruby
mit
188
master
581
# frozen_string_literal: true module Fields class ChoiceField < Field serialize :validations, Validations::ChoiceField serialize :options, NonConfigurable def stored_type :integer end def attached_choices? true end protected def interpret_extra_to(model, accessibilit...
github
rails-engine/form_core
https://github.com/rails-engine/form_core
test/dummy/app/models/fields/date_range_field.rb
Ruby
mit
188
master
788
# frozen_string_literal: true module Fields class DateRangeField < Field serialize :validations, Validations::DateRangeField serialize :options, Options::DateRangeField def interpret_to(model, overrides: {}) check_model_validity!(model) accessibility = overrides.fetch(:accessibility, self.a...
github
rails-engine/form_core
https://github.com/rails-engine/form_core
test/dummy/app/models/fields/text_field.rb
Ruby
mit
188
master
218
# frozen_string_literal: true module Fields class TextField < Field serialize :validations, Validations::TextField serialize :options, Options::TextField def stored_type :string end end end
github
rails-engine/form_core
https://github.com/rails-engine/form_core
test/dummy/app/models/fields/resource_select_field.rb
Ruby
mit
188
master
692
# frozen_string_literal: true module Fields class ResourceSelectField < Field serialize :options, Options::ResourceSelectField serialize :validations, Validations::ResourceSelectField def stored_type :string end delegate :data_source, to: :options def collection data_source.sco...
github
rails-engine/form_core
https://github.com/rails-engine/form_core
test/dummy/app/models/fields/attachment_field.rb
Ruby
mit
188
master
707
# frozen_string_literal: true module Fields class AttachmentField < Field serialize :validations, Validations::AttachmentField serialize :options, NonConfigurable def stored_type :integer end def interpret_to(model, overrides: {}) check_model_validity!(model) accessibility = ...
github
rails-engine/form_core
https://github.com/rails-engine/form_core
test/dummy/app/models/fields/multiple_nested_form_field.rb
Ruby
mit
188
master
1,048
# frozen_string_literal: true module Fields class MultipleNestedFormField < Field after_create do build_nested_form.save! end serialize :validations, Validations::MultipleNestedFormField serialize :options, NonConfigurable def attached_nested_form? true end def interpret_to...
github
rails-engine/form_core
https://github.com/rails-engine/form_core
test/dummy/app/models/fields/select_field.rb
Ruby
mit
188
master
545
# frozen_string_literal: true module Fields class SelectField < Field serialize :validations, Validations::SelectField serialize :options, Options::SelectField def stored_type :string end def attached_choices? true end protected def interpret_extra_to(model, accessib...
github
rails-engine/form_core
https://github.com/rails-engine/form_core
test/dummy/app/models/fields/embeds/datetime_range.rb
Ruby
mit
188
master
623
# frozen_string_literal: true module Fields module Embeds class DatetimeRange < VirtualModel attribute :begin, :datetime attribute :end, :datetime validates :begin, presence: true validates :end, timeliness: { after: :begin, ...
github
rails-engine/form_core
https://github.com/rails-engine/form_core
test/dummy/app/models/fields/embeds/date_range.rb
Ruby
mit
188
master
615
# frozen_string_literal: true module Fields module Embeds class DateRange < VirtualModel attribute :begin, :datetime attribute :end, :datetime validates :begin, presence: true validates :end, timeliness: { after: :begin, ...
github
rails-engine/form_core
https://github.com/rails-engine/form_core
test/dummy/app/models/fields/embeds/decimal_range.rb
Ruby
mit
188
master
505
# frozen_string_literal: true module Fields module Embeds class DecimalRange < VirtualModel attribute :begin, :decimal attribute :end, :decimal validates :begin, :end, presence: true, numericality: { only_integer: false } validates :end, n...
github
rails-engine/form_core
https://github.com/rails-engine/form_core
test/dummy/app/models/fields/embeds/integer_range.rb
Ruby
mit
188
master
504
# frozen_string_literal: true module Fields module Embeds class IntegerRange < VirtualModel attribute :begin, :integer attribute :end, :integer validates :begin, :end, presence: true, numericality: { only_integer: true } validates :end, nu...
github
rails-engine/form_core
https://github.com/rails-engine/form_core
test/dummy/app/models/fields/options/datetime_field.rb
Ruby
mit
188
master
4,564
# frozen_string_literal: true module Fields::Options class DatetimeField < FieldOptions attribute :begin_from, :string, default: "unlimited" enum begin_from: { unlimited: "unlimited", now: "now", time: "time", minutes_before_end: "minutes_before_end" }, _prefix: :begin_from a...
github
rails-engine/form_core
https://github.com/rails-engine/form_core
test/dummy/app/models/fields/options/resource_select_field.rb
Ruby
mit
188
master
202
# frozen_string_literal: true module Fields::Options class ResourceSelectField < FieldOptions include Fields::Options::DataSource attribute :strict_select, :boolean, default: true end end
github
rails-engine/form_core
https://github.com/rails-engine/form_core
test/dummy/app/models/fields/options/integer_field.rb
Ruby
mit
188
master
290
# frozen_string_literal: true module Fields::Options class IntegerField < FieldOptions attribute :step, :integer, default: 0 validates :step, numericality: { only_integer: true, greater_than_or_equal_to: 0 } end end
github
rails-engine/form_core
https://github.com/rails-engine/form_core
test/dummy/app/models/fields/options/multiple_resource_select_field.rb
Ruby
mit
188
master
210
# frozen_string_literal: true module Fields::Options class MultipleResourceSelectField < FieldOptions include Fields::Options::DataSource attribute :strict_select, :boolean, default: true end end
github
rails-engine/form_core
https://github.com/rails-engine/form_core
test/dummy/app/models/fields/options/datetime_range_field.rb
Ruby
mit
188
master
9,755
# frozen_string_literal: true module Fields::Options class DatetimeRangeField < FieldOptions attribute :begin_from, :string, default: "unlimited" enum begin_from: { unlimited: "unlimited", now: "now", time: "time", minutes_before_end: "minutes_before_end" }, _prefix: :begin_from ...
github
rails-engine/form_core
https://github.com/rails-engine/form_core
test/dummy/app/models/fields/options/date_range_field.rb
Ruby
mit
188
master
9,237
# frozen_string_literal: true module Fields::Options class DateRangeField < FieldOptions attribute :begin_from, :string, default: "unlimited" enum begin_from: { unlimited: "unlimited", today: "today", date: "date", days_before_end: "days_before_end" }, _prefix: :begin_from at...
github
rails-engine/form_core
https://github.com/rails-engine/form_core
test/dummy/app/models/fields/options/decimal_field.rb
Ruby
mit
188
master
259
# frozen_string_literal: true module Fields::Options class DecimalField < FieldOptions attribute :step, :decimal, default: 0.01 validates :step, numericality: { greater_than_or_equal_to: 0.0 } end end
github
rails-engine/form_core
https://github.com/rails-engine/form_core
test/dummy/app/models/fields/options/date_field.rb
Ruby
mit
188
master
4,279
# frozen_string_literal: true module Fields::Options class DateField < FieldOptions attribute :begin_from, :string, default: "unlimited" enum begin_from: { unlimited: "unlimited", today: "today", date: "date", days_before_end: "days_before_end" }, _prefix: :begin_from attribu...
github
rails-engine/form_core
https://github.com/rails-engine/form_core
test/dummy/app/models/fields/options/decimal_range_field.rb
Ruby
mit
188
master
5,635
# frozen_string_literal: true module Fields::Options class DecimalRangeField < FieldOptions attribute :begin_from, :string, default: "unrestricted" enum begin_from: { unrestricted: "unrestricted", value: "value", offsets_before_end: "offsets_before_end" }, _prefix: :begin_from attr...
github
rails-engine/form_core
https://github.com/rails-engine/form_core
test/dummy/app/models/fields/options/integer_range_field.rb
Ruby
mit
188
master
5,635
# frozen_string_literal: true module Fields::Options class IntegerRangeField < FieldOptions attribute :begin_from, :string, default: "unrestricted" enum begin_from: { unrestricted: "unrestricted", value: "value", offsets_before_end: "offsets_before_end" }, _prefix: :begin_from attr...
github
rails-engine/form_core
https://github.com/rails-engine/form_core
test/dummy/app/models/fields/validations/multiple_resource_select_field.rb
Ruby
mit
188
master
201
# frozen_string_literal: true module Fields::Validations class MultipleResourceSelectField < FieldOptions prepend Fields::Validations::Presence prepend Fields::Validations::Length end end
github
rails-engine/form_core
https://github.com/rails-engine/form_core
test/dummy/app/models/fields/validations/text_field.rb
Ruby
mit
188
master
223
# frozen_string_literal: true module Fields::Validations class TextField < FieldOptions prepend Fields::Validations::Presence prepend Fields::Validations::Length prepend Fields::Validations::Format end end
github
rails-engine/form_core
https://github.com/rails-engine/form_core
test/dummy/app/models/concerns/enum_attribute_localizable.rb
Ruby
mit
188
master
1,031
# frozen_string_literal: true module EnumAttributeLocalizable extend ActiveSupport::Concern module ClassMethods def human_enum_value(attribute, value, options = {}) parts = attribute.to_s.split(".") attribute = parts.pop.pluralize attributes_scope = "#{i18n_scope}.attributes" if p...
github
rails-engine/form_core
https://github.com/rails-engine/form_core
test/dummy/app/models/concerns/acts_as_default_value.rb
Ruby
mit
188
master
4,932
# frozen_string_literal: true # https://github.com/FooBarWidget/default_value_for # # Copyright (c) 2008-2012 Phusion # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, i...
github
rails-engine/form_core
https://github.com/rails-engine/form_core
test/dummy/app/models/concerns/forms/fake.rb
Ruby
mit
188
master
2,086
# frozen_string_literal: true module Forms module Fake extend ActiveSupport::Concern def build_random_fields(type_key_seq:) transaction(requires_new: true) do type_key_seq.each do |type_key| if type_key.is_a? Hash type_key.each do |k, v| klass = Fields::MAP[...
github
rails-engine/form_core
https://github.com/rails-engine/form_core
test/dummy/app/models/concerns/form_core/acts_as_default_value.rb
Ruby
mit
188
master
4,725
# frozen_string_literal: true # https://github.com/FooBarWidget/default_value_for # # Copyright (c) 2008-2012 Phusion # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, i...
github
rails-engine/form_core
https://github.com/rails-engine/form_core
test/dummy/app/models/concerns/form_core/active_storage_bridge/attached/macros.rb
Ruby
mit
188
master
2,938
# frozen_string_literal: true module FormCore module ActiveStorageBridge module Attached # Provides the class-level DSL for declaring that an Active Entity model has attached blobs. module Macros extend ActiveSupport::Concern module ClassMethods def has_one_attached(name) ...
github
rails-engine/form_core
https://github.com/rails-engine/form_core
test/dummy/app/models/concerns/fields/helper.rb
Ruby
mit
188
master
466
# frozen_string_literal: true module Fields module Helper extend ActiveSupport::Concern def options_configurable? options.is_a?(FieldOptions) && options.attributes.any? end def validations_configurable? validations.is_a?(FieldOptions) && validations.attributes.any? end def atta...
github
rails-engine/form_core
https://github.com/rails-engine/form_core
test/dummy/app/models/concerns/fields/options/data_source.rb
Ruby
mit
188
master
813
# frozen_string_literal: true module Fields module Options::DataSource extend ActiveSupport::Concern included do attribute :data_source_type, :string, default: DataSources::Empty.to_s ::DataSource.descendants.each do |klass| key = :"#{klass.type_key}_data_source" embeds_one key,...
github
rails-engine/form_core
https://github.com/rails-engine/form_core
test/dummy/app/models/concerns/fields/validations/acceptance.rb
Ruby
mit
188
master
376
# frozen_string_literal: true module Fields module Validations::Acceptance extend ActiveSupport::Concern included do attribute :acceptance, :boolean, default: false end def interpret_to(model, field_name, _accessibility, _options = {}) super return unless acceptance model.v...
github
rails-engine/form_core
https://github.com/rails-engine/form_core
test/dummy/app/models/concerns/fields/validations/confirmation.rb
Ruby
mit
188
master
384
# frozen_string_literal: true module Fields module Validations::Confirmation extend ActiveSupport::Concern included do attribute :confirmation, :boolean, default: false end def interpret_to(model, field_name, _accessibility, _options = {}) super return unless confirmation m...
github
rails-engine/form_core
https://github.com/rails-engine/form_core
test/dummy/app/models/concerns/fields/validations/exclusion.rb
Ruby
mit
188
master
961
# frozen_string_literal: true module Fields module Validations::Exclusion extend ActiveSupport::Concern included do embeds_one :exclusion, class_name: "Fields::Validations::Exclusion::ExclusionOptions" accepts_nested_attributes_for :exclusion after_initialize do build_exclusion un...
github
rails-engine/form_core
https://github.com/rails-engine/form_core
test/dummy/app/models/concerns/fields/validations/numericality.rb
Ruby
mit
188
master
1,896
# frozen_string_literal: true module Fields module Validations::Numericality extend ActiveSupport::Concern included do embeds_one :numericality, class_name: "Fields::Validations::Numericality::NumericalityOptions" accepts_nested_attributes_for :numericality after_initialize do bui...
github
rails-engine/form_core
https://github.com/rails-engine/form_core
test/dummy/app/models/concerns/fields/validations/format.rb
Ruby
mit
188
master
1,085
# frozen_string_literal: true module Fields module Validations::Format extend ActiveSupport::Concern included do embeds_one :format, class_name: "Fields::Validations::Format::FormatOptions" accepts_nested_attributes_for :format after_initialize do build_format unless format ...
github
rails-engine/form_core
https://github.com/rails-engine/form_core
test/dummy/app/models/concerns/fields/validations/length.rb
Ruby
mit
188
master
1,744
# frozen_string_literal: true module Fields module Validations::Length extend ActiveSupport::Concern included do embeds_one :length, class_name: "Fields::Validations::Length::LengthOptions" accepts_nested_attributes_for :length after_initialize do build_length unless length ...
github
rails-engine/form_core
https://github.com/rails-engine/form_core
test/dummy/app/models/concerns/fields/validations/inclusion.rb
Ruby
mit
188
master
961
# frozen_string_literal: true module Fields module Validations::Inclusion extend ActiveSupport::Concern included do embeds_one :inclusion, class_name: "Fields::Validations::Inclusion::InclusionOptions" accepts_nested_attributes_for :inclusion after_initialize do build_inclusion un...
github
rails-engine/form_core
https://github.com/rails-engine/form_core
test/dummy/app/models/concerns/fields/validations/presence.rb
Ruby
mit
188
master
368
# frozen_string_literal: true module Fields module Validations::Presence extend ActiveSupport::Concern included do attribute :presence, :boolean, default: false end def interpret_to(model, field_name, _accessibility, _options = {}) super return unless presence model.validat...
github
rails-engine/form_core
https://github.com/rails-engine/form_core
test/dummy/app/presenters/application_presenter.rb
Ruby
mit
188
master
207
# frozen_string_literal: true class ApplicationPresenter < SimpleDelegator def initialize(model, view, options = {}) super(model) @model = model @view = view @options = options end end
github
rails-engine/form_core
https://github.com/rails-engine/form_core
test/dummy/app/presenters/concerns/fields/presenter_for_number_field.rb
Ruby
mit
188
master
806
# frozen_string_literal: true module Fields module PresenterForNumberField extend ActiveSupport::Concern def min return if @model.validations.numericality.lower_bound_check_disabled? min = @model.validations.numericality.lower_bound_value integer_only? ? min.to_i : min end def ma...
github
rails-engine/form_core
https://github.com/rails-engine/form_core
test/dummy/app/presenters/fields/multiple_resource_select_field_presenter.rb
Ruby
mit
188
master
893
# frozen_string_literal: true module Fields class MultipleResourceSelectFieldPresenter < FieldPresenter MAX_HARD_CODE_ITEMS_SIZE = 20 def include_blank? required? end def value_for_preview super&.join(", ") end def can_custom_value? !@model.options.strict_select end ...
github
rails-engine/form_core
https://github.com/rails-engine/form_core
test/dummy/app/presenters/fields/date_range_field_presenter.rb
Ruby
mit
188
master
2,996
# frozen_string_literal: true module Fields class DateRangeFieldPresenter < CompositeFieldPresenter def value_for_preview record = value return unless record from = (I18n.l(record.begin.in_time_zone.to_date) if record.begin && record.begin != -Float::INFINITY) to = (I18n....
github
rails-engine/form_core
https://github.com/rails-engine/form_core
test/dummy/app/presenters/fields/multiple_attachment_field_presenter.rb
Ruby
mit
188
master
421
# frozen_string_literal: true module Fields class MultipleAttachmentFieldPresenter < FieldPresenter def value_for_preview ids = value return if ids.blank? blobs = ActiveStorage::Blob.where(id: ids) return if blobs.blank? blobs.map do |blob| @view.link_to blob.filename, @vi...
github
rails-engine/form_core
https://github.com/rails-engine/form_core
test/dummy/app/presenters/fields/decimal_range_field_presenter.rb
Ruby
mit
188
master
2,721
# frozen_string_literal: true module Fields class DecimalRangeFieldPresenter < CompositeFieldPresenter def value_for_preview record = value return unless record "#{record.begin} ~ #{record.end}" end def begin_options { min: min_begin, max: max_begin, disabled: begin_disabled? }....
github
rails-engine/form_core
https://github.com/rails-engine/form_core
test/dummy/app/presenters/fields/multiple_resource_field_presenter.rb
Ruby
mit
188
master
974
# frozen_string_literal: true module Fields class MultipleResourceFieldPresenter < FieldPresenter MAX_HARD_CODE_ITEMS_SIZE = 20 def include_blank? required? end def value_for_preview return unless @model.collection return if @model.collection.none? collection .where...
github
rails-engine/form_core
https://github.com/rails-engine/form_core
test/dummy/app/presenters/fields/composite_field_presenter.rb
Ruby
mit
188
master
225
# frozen_string_literal: true module Fields class CompositeFieldPresenter < FieldPresenter def value target&.send(@model.name) end def value_for_preview target&.send(@model.name) end end end
github
rails-engine/form_core
https://github.com/rails-engine/form_core
test/dummy/app/presenters/fields/date_field_presenter.rb
Ruby
mit
188
master
1,781
# frozen_string_literal: true module Fields class DateFieldPresenter < FieldPresenter def value super&.in_time_zone&.to_date end def value_for_preview value = self.value I18n.l(value) if value end def field_options return {} if access_readonly? options = {} ...