Skip to content

Commit

Permalink
NEW In-line edit is an opt-out configuration setting
Browse files Browse the repository at this point in the history
  • Loading branch information
ScopeyNZ committed Aug 23, 2018
1 parent 786ff28 commit c45bcd6
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 2 deletions.
6 changes: 6 additions & 0 deletions README.md
Expand Up @@ -176,6 +176,12 @@ class MyElement extends BaseElement
}
```

#### In-line Editing

By default elements can be edited in the CMS using an inline form where all your elements appear together. For elements
that are more complex you can disable the in-line edit form by setting `private static $inline_editable = false` in your
element class. A `GridFieldDetailForm` will be used to edit blocks that are not in-line editable.

### Defining your own HTML

`MyElement` will be rendered into a `MyElement.ss` template with the `ElementHolder.ss` wrapper. Changing the holder
Expand Down
2 changes: 1 addition & 1 deletion _config/graphql.yml
Expand Up @@ -10,7 +10,7 @@ SilverStripe\GraphQL\Manager:
types:
# Expose common static fields for the ElementEditor component to use for preview summaries
DNADesign\Elemental\Models\BaseElement:
fields: [ID, LastEdited, AbsoluteLink, Title, ShowTitle, Sort, BlockSchema]
fields: [ID, LastEdited, AbsoluteLink, Title, ShowTitle, Sort, BlockSchema, InlineEditable]
operations:
copyToStage: true
readOne: true
Expand Down
2 changes: 1 addition & 1 deletion client/dist/js/bundle.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions client/src/types/elementType.js
Expand Up @@ -5,6 +5,7 @@ const elementType = {
ID: PropTypes.number.isRequired,
Title: PropTypes.string,
BlockSchema: PropTypes.object,
InlineEditable: PropTypes.bool,
};

export { elementType };
21 changes: 21 additions & 0 deletions src/Models/BaseElement.php
Expand Up @@ -19,6 +19,7 @@
use SilverStripe\Forms\NumericField;
use SilverStripe\Forms\TextField;
use SilverStripe\ORM\DataObject;
use SilverStripe\ORM\FieldType\DBBoolean;
use SilverStripe\ORM\FieldType\DBField;
use SilverStripe\ORM\FieldType\DBHTMLText;
use SilverStripe\Security\Member;
Expand Down Expand Up @@ -76,6 +77,7 @@ class BaseElement extends DataObject

private static $casting = [
'BlockSchema' => DBObjectType::class,
'InlineEditable' => DBBoolean::class,
];

private static $versioned_gridfield_extensions = true;
Expand Down Expand Up @@ -128,6 +130,15 @@ class BaseElement extends DataObject
*/
private static $disable_pretty_anchor_name = false;

/**
* Set to false to prevent an in-line edit form from showing in an elemental area. Instead the element will be
* clickable and a GridFieldDetailForm will be used.
*
* @config
* @var bool
*/
private static $inline_editable = true;

/**
* Store used anchor names, this is to avoid title clashes
* when calling 'getAnchor'
Expand Down Expand Up @@ -331,6 +342,16 @@ public function getType()
return _t(__CLASS__ . '.BlockType', 'Block');
}

/**
* Proxy through to configuration setting 'inline_editable'
*
* @return bool
*/
public function inlineEditable()
{
return static::config()->get('inline_editable');
}

/**
* @param ElementController $controller
*
Expand Down

0 comments on commit c45bcd6

Please sign in to comment.