Coder Social home page Coder Social logo

reasons-craft3's People

Contributors

brandonkelly avatar mmikkel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

reasons-craft3's Issues

Package installs correctly, but then all pages display the error (presumably due to config rebuild as `project-config/rebuild` also throws same error):

Experiencing something similar when trying to add Reasons to an existing site. Package installs correctly, but then all pages display the error (presumably due to config rebuild as project-config/rebuild also throws same error):

error: SQLSTATE[42703]: Undefined column: 7 ERROR:  column reasons.fieldlayoutid does not exist
LINE 3: ...fieldlayouts" "fieldlayouts" ON fieldlayouts.id = reasons.fi...
                                                             ^
HINT:  Perhaps you meant to reference the column "reasons.fieldLayoutId".
The SQL being executed was: SELECT "reasons"."uid", "reasons"."conditionals", "fieldlayouts"."uid" AS "fieldLayoutUid"
FROM "reasons" "reasons"
INNER JOIN "fieldlayouts" "fieldlayouts" ON fieldlayouts.id = reasons.fieldLayoutId

Can send through a DB dump and the config/project directory if needed ๐Ÿ‘

Craft: Pro 3.5.14
Reasons: 2.2.2
DB Engine: PostgreSQL 12.1

Originally posted by @slavanossar in #9 (comment)

Duplicate query issue with large data

Hi,

We have a craft cms site, with nearly 300 sections, each section has only one entry type with 5 or 6 conditional fields. We see a huge delay when switching over control panel menu pages. This occurs on all menus even when switching between settings, utilities etc,

Our initial findings are showing there are a lot of duplicate queries initiated by reasons plugin is the cause for this delay.
For example, when we load the utilities page, after disabling the plugin only 60 odd queries were running, After enabling we see nearly 12000 queries were running. See attached,
craft-with-reasons
Craft-without-reasons

Could we load the queries only on the pages needed?

System info:
PHP version 7.4.24
OS version Linux 5.4.0-91-generic
Database driver & version MySQL 5.7.35
Image driver & version GD 7.4.24
Craft edition & version Craft Pro 3.7.28
Yii version 2.0.44
Twig version v2.14.10
Guzzle version 7.4.1

Reason plugin version - 2.2.5

Broken in Craft 3.5.18?

At least it looks that way. Updated and now Reasons is failing, although I can't see any obvious errors appearing, the fields with conditional rules applied just don't appear.

The latest release of Craft includes many accessibility improvements which could be related.

saveFieldLayoutConditionals sometimes is passed invalid JSON

I've tried tracking this down a little in the code but have been unable to work out just where the issue starts here.

Under certain conditions the $conditionals JSON passed to the saveFieldLayoutConditionals() method in the ReasonsService doesn't contain valid JSON and the whole thing falls apart leaving the dashboard inaccessible etc. It's like the closing brackets of the array of conditionals are missing when I dump out the failing code.

My field layout is as follows.

competitionType - radio button field with 3 values - roundRobin, elimination, winnerStaysOn
blindDrawForEachRound - lightswitch field
blindDrawRounds - matrix
roundRobinRounds - number field

If a user selects competitionType:elimination then the blindDrawForEachRound should be visible, if they turn that on, the blindDrawRounds should be visible.

If a user selects competitionType:roundRobin the roundRobinRounds should be visible.

The issue appears to present if I set up the second conditional on the competitionType toggle field. Somehow the JSON doesn't get wrapped up properly and I've struggled (although I've not looked at it in-depth) to easily find where that's hapening.

Let me know if you want a DB/project config or anything.

Cheers

Neo Matrix field designer support

Hey,

Awesome work on Reasons for Craft 3! ๐ŸŽ‰

I was wondering if you'd be able to support Neo Matrix field designer? I see the action in Neo's fld is fields/save-field, but you don't seem to be doing anything with this yet here:

FIELDS_ACTION: 'fields/save-field',

There's obviously more that would need to be done in order to support Neo but I would really appreciate it if you would consider adding support for Neo Matrix's fld ๐Ÿ˜„

Not working in Safari 15

Not working in Safari 15, shows everything and has no effect. Works perfectly in Chrome and Firefox.

System:
Safari 15.0
Craft Pro 3.7.16
Reasons 2.2.5

Developer console reports:

ReferenceError: Can't find variable: BroadcastChannel
init โ€” DraftEditor.js:118
constructor โ€” garnish.js:764
(anonym funksjon) โ€” garnish.js:40
(anonym funksjon) โ€” garnish.js:40

console command breaks

Hi Mats,

Thanks so much for porting this. I've found a couple of issues locally which I was going to PR but I'm not 100% sure if my "fix" has side-effects I've not gone over.

If you run ./craft project-config/sync --force in terminal the plugin throws an error about getBodyParam() not existing which is true, the console version of the Craft app Request class doesn't have this method.

I "fixed" this by simply wrapping the call to it which is within the EVENT_AFTER_SAVE_FIELD_LAYOUT handler, in a check:

          if (!Craft::$app->getRequest()->getIsConsoleRequest())
          {
            // getBodyParam doesn't exist in console commands such as ./craft project-config/sync -- force
            $conditionals = Craft::$app->getRequest()->getBodyParam('_reasons', null);
          }

which meant the rest of the code ran through with it a null value (so it just returns) but obviously that means the thing that should be happening isn't happening so not sure if that's an issue, hence no PR for this. I think it's OK because you're attempting to handle save field events from the dashboard in here but I don't know if syncing project config with the force flag will mean the reasons stuff gets lost?

I'll open a different issue for the other thing I've found.

Cheers.

Update from Craft 3 + Reasons to Craft 4: how to get fields' conditions from template?

I've just updated from Craft 3 to Craft 4. I was previously using the Reasons plugin for CP but also front-end purpose. On front-end, I was printing field layouts and show/hide the fields based on the same Reasons conditions found in the CP.

Unfortunately, this plugin has been stopped for Craft 4 in profit of the native conditional fields. However, I don't find out the equivalent of what I could achieve using Reasons.

This is what I was doing in Craft 3 + Reasons:

{% set conditionals = [] %}
% for key, value in craft.app.getPlugins().getPlugin('reasons').reasons.getData().conditionals  %}
	{%
		if 'section' in key
		and (key | split(':') | last) | number_format == craft.app.sections.getSectionByHandle('companies').id ?? -1
	%}
		{% set conditionals = value %}
	{% endif %}
{% endfor %}

{% set rules = [] %}
{% set syncedFields = [] %}
{% set syncedHandles = [] %}
{% set hiddenFields = [] %}
{% for id, condition in conditionals %}
	{% set syncedFields = syncedFields | merge([condition.0.0.0.fieldId ?? null]) | filter | unique %}
	{% set handle = craft.app.fields.getFieldById(condition.0.0.0.fieldId ?? null).handle ?? null %}
	{% set syncedHandles = syncedHandles | merge(["{handle}: '{value}'" | t({
		handle: handle,
		value: company[handle].value ?? company[handle] ?? null
	})]) | filter | unique %}
	{% set hiddenFields = hiddenFields | merge([id ?? null]) | filter %}
	{% set condition = {
		sync: condition.0.0.0.fieldId ?? null,
		field: id ?? null,
		rule: '{compare} {value}' | t({
			compare: condition.0.0.0.compare,
			value: condition.0.0.0.value
		})
	} %}
{% endfor %}

In my case, the intended context here is quite simple: it's checking a Lightswitch field from another field. If the main field is switched on, subfields will be shown.

What would be the equivalent in Craft 4?

Broken in Craft 3.7.46.

Updated to Latest Craft CMS version 3.7.46 from 3.7.45.2 and it's broken the reasons plugin functionality. I can't see any obvious errors appearing, the fields with conditional rules are applied but they just don't appear in the entries.

Reasons doesn't work in entry select field "Add new entry" modals

I've got an entry type with a lightbox to toggle between to fields - a Matrix field and a Super Table field. The toggle applies to the entire field and works perfectly in the normal "Add new entry" from the "All Entries" dashboard view.

What doesn't work is the toggle when you opt to add a new entry from the "Select an Entry" entry field. Please see diagram below for explanation

Test-ezyVet
.

Conditional fields don't show after updating to 3.5.3?

I updated to 3.5.3 today and it looks to have broken Reasons. I'm able to access the Conditional options when editing the Entry Type, but the conditional field doesn't show at all after adding criteria. In the second screenshot, the field should show to the right of 'Child Layout'.

Screen Shot 2020-08-13 at 2 53 00 pm
Screen Shot 2020-08-13 at 2 53 29 pm

Integrity constraint validation with project config

I've spent a while trying to debug why a deployment has been failing. My site uses project-config.

Craft: 3.5.11.1
Reasons: 2.2.1
DB Engine: MySQL

Steps to reproduce:

  • git pull of my project, which contains project config
  • composer install
  • craft setup

The final part of craft setup is applying the project config, but this fails with the SQL error below. Removing the reasons_conditionals folder from config/project allows the installation to complete successfully.

Comparing the databases, the value for fieldLayoutId (0) that's being inserted here relates to a different/incompatible field layout on this installation. My guess is that fieldLayoutId shouldn't be in the table at all, and the UUID used instead? There's apparently no fieldLayoutId in the yaml.

Aside from this, I can't get Reasons to work on this version of Craft even when it is configured correctly!

Applying changes from your project config files ... error: SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`craft3`.`craft_reasons`, CONSTRAINT `craft_reasons_fieldLayoutId_fk` FOREIGN KEY (`fieldLayoutId`) REFERENCES `craft_fieldlayouts` (`id`) ON DELETE CASCADE ON UPDATE CASCADE) The SQL being executed was: INSERT INTO `craft_reasons` (`fieldLayoutId`, `conditionals`, `uid`, `dateCreated`, `dateUpdated`) VALUES (0, '{\"2e8dd7f7-f84f-4c0a-b3b8-8ac1bce79d9d\":[[{\"field\":\"e99e7f78-3ce1-4e44-b165-a8edbc360aca\",\"compare\":\"==\",\"value\":\"true\"}]],\"9fcbd106-b808-47ec-942b-668235124254\":[[{\"field\":\"e99e7f78-3ce1-4e44-b165-a8edbc360aca\",\"compare\":\"==\",\"value\":\"true\"}]],\"6d8fcd42-634a-4dac-b682-ede47aba83f0\":[[{\"field\":\"e99e7f78-3ce1-4e44-b165-a8edbc360aca\",\"compare\":\"==\",\"value\":\"true\"}]],\"c01c6210-ed29-4fe6-a390-87eef631095c\":[[{\"field\":\"e99e7f78-3ce1-4e44-b165-a8edbc360aca\",\"compare\":\"==\",\"value\":\"true\"}]],\"19ced37f-881d-491f-898b-91ca9de7057e\":[[{\"field\":\"e99e7f78-3ce1-4e44-b165-a8edbc360aca\",\"compare\":\"==\",\"value\":\"true\"}]],\"063f327a-3e45-4cdf-b47c-43359485a7bc\":[[{\"field\":\"e99e7f78-3ce1-4e44-b165-a8edbc360aca\",\"compare\":\"==\",\"value\":\"true\"}]]}', '2ca19fa0-117f-41d6-81f2-3f2fb1e1c6dd', '2020-09-21 21:25:33', '2020-09-21 21:25:33')

Not working in Craft version 3.7.16

Hi!

Could it be that the plugin doesn't work with Craft version 3.7.16? The plugin used to work but since version 3.7.16 no options appear when editing fields for sections and the conditions are also gone.

Thanks,
Dirk

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.