Fix layout block actions + z index editor sidebar

This commit is contained in:
Julien Nahum 2024-02-10 13:20:41 +01:00
parent e5dc3f1bd4
commit b7c4f8e010
2 changed files with 15 additions and 17 deletions

View File

@ -6,7 +6,7 @@ use Illuminate\Contracts\Validation\Rule;
use Illuminate\Contracts\Validation\DataAwareRule; use Illuminate\Contracts\Validation\DataAwareRule;
use Illuminate\Support\Str; use Illuminate\Support\Str;
class FormPropertyLogicRule implements Rule, DataAwareRule class FormPropertyLogicRule implements Rule, DataAwareRule
{ {
const ACTIONS_VALUES = [ const ACTIONS_VALUES = [
@ -52,7 +52,7 @@ class FormPropertyLogicRule implements Rule, DataAwareRule
'type' => 'enum', 'type' => 'enum',
'values' => [true] 'values' => [true]
] ]
], ],
'content_length_equals' => [ 'content_length_equals' => [
'expected_type' => 'number' 'expected_type' => 'number'
], ],
@ -478,7 +478,7 @@ class FormPropertyLogicRule implements Rule, DataAwareRule
private $field = []; private $field = [];
private $data = []; private $data = [];
private function checkBaseCondition($condition) private function checkBaseCondition($condition)
{ {
if (!isset($condition['value'])) { if (!isset($condition['value'])) {
@ -498,7 +498,7 @@ class FormPropertyLogicRule implements Rule, DataAwareRule
$this->conditionErrors[] = 'missing condition property type'; $this->conditionErrors[] = 'missing condition property type';
return; return;
} }
if (!isset($condition['value']['operator'])) { if (!isset($condition['value']['operator'])) {
$this->isConditionCorrect = false; $this->isConditionCorrect = false;
$this->conditionErrors[] = 'missing condition operator'; $this->conditionErrors[] = 'missing condition operator';
@ -527,8 +527,6 @@ class FormPropertyLogicRule implements Rule, DataAwareRule
return; return;
} }
// TODO: find what's causing the issue when saving this validation rule :(
$type = self::CONDITION_MAPPING[$typeField]['comparators'][$operator]['expected_type']; $type = self::CONDITION_MAPPING[$typeField]['comparators'][$operator]['expected_type'];
if (is_array($type)) { if (is_array($type)) {
@ -562,7 +560,7 @@ class FormPropertyLogicRule implements Rule, DataAwareRule
return true; return true;
} }
private function checkConditions($conditions) private function checkConditions($conditions)
{ {
if (array_key_exists('operatorIdentifier', $conditions)) { if (array_key_exists('operatorIdentifier', $conditions)) {
if (($conditions['operatorIdentifier'] !== 'and') && ($conditions['operatorIdentifier'] !== 'or')) { if (($conditions['operatorIdentifier'] !== 'and') && ($conditions['operatorIdentifier'] !== 'or')) {
@ -591,14 +589,14 @@ class FormPropertyLogicRule implements Rule, DataAwareRule
} }
} }
private function checkActions($conditions) private function checkActions($actions)
{ {
if (is_array($conditions) && count($conditions) > 0) { if (is_array($actions) && count($actions) > 0) {
foreach($conditions as $val){ foreach($actions as $val){
if (!in_array($val, static::ACTIONS_VALUES) || if (!in_array($val, static::ACTIONS_VALUES) ||
(in_array($this->field["type"], ['nf-text', 'nf-code', 'nf-page-break', 'nf-divider', 'nf-image']) && !in_array($val, ['hide-block'])) || (in_array($this->field["type"], ['nf-text', 'nf-code', 'nf-page-break', 'nf-divider', 'nf-image']) && !in_array($val, ['hide-block', 'show-block'])) ||
(isset($this->field["hidden"]) && $this->field["hidden"] && !in_array($val, ['show-block', 'require-answer'])) || (isset($this->field["hidden"]) && $this->field["hidden"] && !in_array($val, ['show-block', 'require-answer'])) ||
(isset($this->field["required"]) && $this->field["required"] && !in_array($val, ['make-it-optional', 'hide-block', 'disable-block'])) || (isset($this->field["required"]) && $this->field["required"] && !in_array($val, ['make-it-optional', 'hide-block', 'disable-block'])) ||
(isset($this->field["disabled"]) && $this->field["disabled"] && !in_array($val, ['enable-block', 'require-answer', 'make-it-optional'])) (isset($this->field["disabled"]) && $this->field["disabled"] && !in_array($val, ['enable-block', 'require-answer', 'make-it-optional']))
) { ) {
$this->isActionCorrect = false; $this->isActionCorrect = false;
@ -617,7 +615,7 @@ class FormPropertyLogicRule implements Rule, DataAwareRule
* @param mixed $value * @param mixed $value
* @return bool * @return bool
*/ */
public function passes($attribute, $value) public function passes($attribute, $value)
{ {
$this->setProperty($attribute); $this->setProperty($attribute);
if(isset($value["conditions"])){ if(isset($value["conditions"])){
@ -632,7 +630,7 @@ class FormPropertyLogicRule implements Rule, DataAwareRule
* Get the validation error message. * Get the validation error message.
* *
*/ */
public function message() public function message()
{ {
$message = null; $message = null;
if (! $this->isConditionCorrect) { if (! $this->isConditionCorrect) {

View File

@ -1,7 +1,7 @@
<template> <template>
<transition @leave="(el,done) => sidebarMotion?.leave(done)"> <transition @leave="(el,done) => sidebarMotion?.leave(done)">
<div v-if="show" ref="sidebar" <div v-if="show" ref="sidebar"
class="absolute shadow-lg shadow-gray-800/30 top-0 h-[calc(100vh-53px)] right-0 lg:shadow-none lg:relative bg-white w-full md:w-1/2 lg:w-2/5 border-l overflow-y-scroll md:max-w-[20rem] flex-shrink-0 z-50" class="absolute shadow-lg shadow-gray-800/30 top-0 h-[calc(100vh-53px)] right-0 lg:shadow-none lg:relative bg-white w-full md:w-1/2 lg:w-2/5 border-l overflow-y-scroll md:max-w-[20rem] flex-shrink-0 z-30"
> >
<slot /> <slot />
</div> </div>