All Projects → codica2 → administrate-field-jsonb

codica2 / administrate-field-jsonb

Licence: MIT license
A plugin to show and edit JSON objects within Administrate.

Programming Languages

javascript
184084 projects - #8 most used programming language
HTML
75241 projects
ruby
36898 projects - #4 most used programming language
CSS
56736 projects

Projects that are alternatives of or similar to administrate-field-jsonb

craft-recipe
A comprehensive recipe FieldType for Craft CMS that includes metric/imperial conversion, portion calculation, and JSON-LD microdata support
Stars: ✭ 23 (-39.47%)
Mutual labels:  field
bombadil
You know, for (PostgreSQL) search
Stars: ✭ 27 (-28.95%)
Mutual labels:  jsonb
react-streamfield
Powerful field for inserting multiple blocks with nesting. (NO LONGER MAINTAINED - See Wagtail 2.13 Release Notes)
Stars: ✭ 34 (-10.53%)
Mutual labels:  field
administrate-field-carrierwave
🌊 A plugin to upload and preview Carrierwave attachments in Administrate
Stars: ✭ 16 (-57.89%)
Mutual labels:  administrate
django-isbn-field
Django model field to store and validate ISBN numbers.
Stars: ✭ 21 (-44.74%)
Mutual labels:  field
nova-phone-number
A Laravel Nova field to format and validate phone numbers.
Stars: ✭ 60 (+57.89%)
Mutual labels:  field
TagField
🏷 Simple Tag Field for SwiftUI 🏷
Stars: ✭ 19 (-50%)
Mutual labels:  field
craft-grid
A field that lets you content manage CSS Grid in Craft CMS.
Stars: ✭ 18 (-52.63%)
Mutual labels:  field
administrate-field-paperclip
Paperclip field plugin for Administrate
Stars: ✭ 14 (-63.16%)
Mutual labels:  administrate
objection-authorize
isomorphic, "magical" authorization integration with Objection.js 🎉
Stars: ✭ 71 (+86.84%)
Mutual labels:  field
react-plough
A library to help tend your react form fields
Stars: ✭ 31 (-18.42%)
Mutual labels:  field
nova-froala-field
A Laravel Nova Froala WYSIWYG Editor Field.
Stars: ✭ 110 (+189.47%)
Mutual labels:  field
architectui-react-theme-free
ArchitectUI React admin template is a simple yet fully customizable admin dashboard for web apps and other software.
Stars: ✭ 105 (+176.32%)
Mutual labels:  adminpanel
Materialtextfield
A different beautiful Floating Edit Text
Stars: ✭ 1,504 (+3857.89%)
Mutual labels:  field
squint
Search PostgreSQL jsonb and hstore columns
Stars: ✭ 26 (-31.58%)
Mutual labels:  jsonb
plenopticam
Light-field imaging application for plenoptic cameras
Stars: ✭ 111 (+192.11%)
Mutual labels:  field
react-forms-processor
A forms processor for React
Stars: ✭ 63 (+65.79%)
Mutual labels:  field
Polygonization-by-Frame-Field-Learning
This repository contains the code for our fast polygonal building extraction from overhead images pipeline.
Stars: ✭ 161 (+323.68%)
Mutual labels:  field
nova-opening-hours-field
Laravel Nova custom field for https://github.com/spatie/opening-hours
Stars: ✭ 33 (-13.16%)
Mutual labels:  field
python-pyfields
Define fields in python classes. Easily.
Stars: ✭ 39 (+2.63%)
Mutual labels:  field

Administrate::Field::Jsonb

A plugin to show and edit JSON objects within Administrate. inspired by Administrate::Field::JSON.

This gem uses jsoneditor.

Installation

Add this line to your application's Gemfile:

gem 'administrate-field-jsonb'

And then execute:

bundle

If you are using asset pipeline, add the following lines to your manifest.js:

//= link administrate-field-jsonb/application.css
//= link administrate-field-jsonb/application.js

The manifest file is at app/assets/config by default.

Usage

ATTRIBUTE_TYPES = {
  # ...
  details: Field::JSONB
}.freeze

If you have some kind of serialization, you can call methods on your object with transform option.

ATTRIBUTE_TYPES = {
  # ...
  details: Field::JSONB.with_options(
    transform: %w[to_h symbolize_keys]
  )
}.freeze

If you want to edit json displaying on show page, you can use advanced_view option (both JSON and arrays are supported).

ATTRIBUTE_TYPES = {
  # ...
  details: Field::JSONB.with_options(transform: %i[to_h symbolize_keys], advanced_view: {
    company:  Field::String,
    position: Field::String,
    skills: Field::JSONB.with_options(advanced_view: {
      'name'  => Field::String,
      'years' => Field::Number.with_options(suffix: ' years')
    })
  }),
  languages: Field::JSONB.with_options(advanced_view: {
    'title' => Field::String,
    'code'  => Field::String,
  })
}.freeze

NOTE: don't define advanced_view option if you want to display JSON with the jsoneditor.

To customize what to display if you have an empty value, use blank_sign option, by default it's -.

ATTRIBUTE_TYPES = {
  # ...
  details: Field::JSONB.with_options(
    blank_sign: 'oops, missed'
  )
}.freeze

How it looks like

Form

Show

jsoneditor mode

advanced_view mode

advanced_view object

advanced_view array

Recipes

If you want to store your JSON in hash format and not a string add this to your model.

def your_field_name=(value)
  self[:your_field_name] = value.is_a?(String) ? JSON.parse(value) : value
end

Example:

def details=(value)
  self[:details] = value.is_a?(String) ? JSON.parse(value) : value
end

If you don't see details in advanced_view, try to add this

transform: %i[to_h symbolize_keys]

or use string keys.

languages: Field::JSONB.with_options(advanced_view: {
  'title' => Field::String,
  'code'  => Field::String,
})

License

Copyright © 2015-2022 Codica. It is released under the MIT License.

About Codica

Codica logo

Administrate::Field::Jsonb is maintained by Codica. The names and logos for Codica are trademarks of Codica.

We love open source software! See our other projects or hire us to design, develop, and grow your product.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].