Skip to content

Commit

Permalink
Merge branch 'release/1.4.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
jalendport committed Aug 8, 2022
2 parents 0df6539 + b78856b commit 195cb05
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 27 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## 1.4.0 - 2022-08-08
### Added
- Added support for craft-twigfield ([#81](https://github.com/besteadfast/craft-preparse-field/pull/81) - thanks @khalwat)

## 1.3.0 - 2022-08-06
### Added
- Added datetime column type option ([#63](https://github.com/besteadfast/craft-preparse-field/pull/63) - thanks @mmikkel)
Expand Down
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "besteadfast/craft-preparse-field",
"description": "A fieldtype that parses Twig when an element is saved and saves the result as plain text.",
"type": "craft-plugin",
"version": "1.3.0",
"version": "1.4.0",
"keywords": [
"craft",
"cms",
Expand All @@ -28,7 +28,8 @@
}
],
"require": {
"craftcms/cms": "^3.2.0"
"craftcms/cms": "^3.2.0",
"nystudio107/craft-twigfield": "^1.0.0"
},
"autoload": {
"psr-4": {
Expand Down
42 changes: 20 additions & 22 deletions src/fields/PreparseFieldType.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,26 +74,24 @@ public static function displayName(): string
public function rules()
{
$rules = parent::rules();
$rules = array_merge($rules, [
['fieldTwig', 'string'],
['fieldTwig', 'default', 'value' => ''],
['columnType', 'string'],
['columnType', 'default', 'value' => ''],
['decimals', 'number'],
['decimals', 'default', 'value' => 0],
['textareaRows', 'number'],
['textareaRows', 'default', 'value' => 5],
['parseBeforeSave', 'boolean'],
['parseBeforeSave', 'default', 'value' => false],
['parseOnMove', 'boolean'],
['parseOnMove', 'default', 'value' => false],
['displayType', 'string'],
['displayType', 'default', 'value' => 'hidden'],
['allowSelect', 'boolean'],
['allowSelect', 'default', 'value' => false],
]);

return $rules;
return array_merge($rules, [
['fieldTwig', 'string'],
['fieldTwig', 'default', 'value' => ''],
['columnType', 'string'],
['columnType', 'default', 'value' => ''],
['decimals', 'number'],
['decimals', 'default', 'value' => 0],
['textareaRows', 'number'],
['textareaRows', 'default', 'value' => 5],
['parseBeforeSave', 'boolean'],
['parseBeforeSave', 'default', 'value' => false],
['parseOnMove', 'boolean'],
['parseOnMove', 'default', 'value' => false],
['displayType', 'string'],
['displayType', 'default', 'value' => 'hidden'],
['allowSelect', 'boolean'],
['allowSelect', 'default', 'value' => false],
]);
}

/**
Expand All @@ -108,7 +106,7 @@ public function getContentColumnType(): string

return $this->columnType;
}

/**
* @return null|string
* @throws LoaderError
Expand Down Expand Up @@ -143,7 +141,7 @@ public function getSettingsHtml()
]
);
}

/**
* @param mixed $value
* @param ElementInterface|null $element
Expand Down
7 changes: 4 additions & 3 deletions src/templates/_components/fields/_settings.twig
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,17 @@
#}

{% import "_includes/forms" as forms %}
{% import "twigfield/twigfield" as twigfield %}

{{ forms.textareaField( {
{{ twigfield.textareaField( {
label: "Twig code to parse"|t,
instructions: "Enter the twig code that you want to parse after the entry has been saved.\nIf the column type is set to Date (datetime), the parsed Twig should output a date formatted as `Y-m-d H:i:s`."|t,
id: 'fieldTwig',
name: 'fieldTwig',
value: field['fieldTwig'],
class: 'code',
rows: 10
}) }}
rows: 10,
}, "Twigfield", "monaco-editor-background-frame") }}

{% set columnType %}
{{ forms.select({
Expand Down

0 comments on commit 195cb05

Please sign in to comment.