This file contains hidden or 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
# adds following new options to presence validator: | |
# | |
# • presence: :cs | |
# • presence: %i[cs en] | |
# • presence: :default_locale | |
module LocalizedPresenceValidator | |
def validate_each(document, attribute, value) | |
field = document.fields[document.database_field_name(attribute)] | |
return super(document, attribute, value) unless field.try(:localized?) |
This file contains hidden or 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
# makes sure that | |
# • we fallback on all :blank? values | |
# • an only on :present? values | |
module Mongoid | |
module Fields | |
module LocalizedPatch | |
def lookup(object) | |
locale = ::I18n.locale |
This file contains hidden or 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
require 'mongoid' | |
module Mongoid | |
class CreateView < Struct.new(:collection_name, :view_on, :pipeline) | |
def self.call(*args) | |
new(*args).call | |
end | |
def call | |
Mongoid.clients.each do |name, _| |
This file contains hidden or 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
import _ from 'lodash' | |
export default class DependentFields extends Modulor.Plugin | |
@defaults = | |
debug: false | |
name: 'Modulor__DependentFields' | |
# add the <%= Bem.bems :modulor_dependent_fields, :scope %> class on parent element | |
# in order to prevent dependent fields influencing for example nested fields | |
scope_selector: "bems(modulor_dependent_fields, scope), bems(modulor_nested_fields, item), form" |
This file contains hidden or 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
export default class Link__NestedFields extends Modulor.Plugin | |
@defaults = | |
debug: false | |
new_item_class_name: "bem(modulor_nested_fields, item, is_new)" | |
regexp: new RegExp("__INDEX_PLACEHOLDER__", 'g') # regexp: new RegExp("<%= Modulor::NestedFieldsBuilder::CHILD_INDEX_STRING %>", 'g') | |
@selector: "bems(modulor_link, nested_fields)" | |
on_init: -> | |
@$element.on "click.#{@options.name}", (e) => |
This file contains hidden or 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
module Modulor | |
module ResourceSelect | |
class BaseController < ApplicationController | |
def index | |
authorize! :read, resource_class | |
respond_to do |format| | |
format.json do | |
render json: collection_query, | |
serializer: ActiveModel::Serializer::CollectionSerializer, |
This file contains hidden or 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
``` | |
Run options: --seed 25431 | |
# Running: | |
Capybara starting Puma... | |
* Version 4.3.5 , codename: Mysterious Traveller | |
* Min threads: 0, max threads: 4 | |
* Listening on tcp://0.0.0.0:40303 |
This file contains hidden or 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
# frozen_string_literal: true | |
module CanCan | |
module ModelAdapters | |
class CustomActiveRecordAdapter < AbstractAdapter | |
def self.inherited(subclass) | |
@subclasses ||= [] | |
@subclasses.insert(0, subclass) | |
end |
OlderNewer