Creating a gutenberg block via a loop & triggering update on button click

Long time WP and PHP developer but new to Gutenberg blocks & React JS—like, really new!

I have a Gutenberg block I’ve made, where I can set 2 numbers, columns & rows. I’m looking to make a grid and then have a WooCom product output in each grid item. So a 2 x 2 would have 4 products etc.

I’m not doing anything fancy with selecting the products, literally just going to type the IDs in and click save, maybe pull the image and title etc so I can see what’s where.

If I add a NumberControl block to my generated grid squares, it’s basically 4 instances of the same component. So I can’t save it. It just overwrites the values with the last instance of the component.

I thought innerBlocks might do it but that just duplicates everything across all the grid squares.

My question is 2 part:

  1. How would I go about doing what I’m describing? Where I dynamically generate components and save the values to arrays etc? I was just going to use an ID for a key, but can’t work out how to do that.
  2. Save querying the database every time a number is entered, how does one trigger the onChange method of a NumberControl component on the click of a button?

Hope that all makes sense, happy to answer any questions. Thank you for looking.

magento2 – Creating a vendor panel in magento 2?

I am new to magento, and I have got a requirement from client.

Background of requirement : There are 10 vendors pincode based and 4 main vendors zone wise, linked with my client. The client wants to route the order based on the nearest pincode vendor. The vendor can accept or deny the order received. Once the vendor denies the order, the order then goes to the main vendor of that zone. I know how to create custom modules but I am not sure how to handle this request and from where to start ?

How can I achieve this functionality and what are the aspects I need to cover in the order fulfillment under this scenario. ? Below are the major requirements on frontend :

  1. The user enters pincode, it is checked from backend and deliverable vendors are listed along with their price list.

  2. Once user selects a vendor and places an order the order is routed to that vendor.

What all will be the tables I need to consider to create module to achieve this requirement. Is there any similar extension for this ? I tried searching for multi vendor module but that seems little different or can I use the same and extend it, can anyone guide me by giving some idea as I have just started learning this framework.

photo editing – Creating a LUT in Photoshop with a Vignette

I’m trying to create an LUT in Photoshop that includes a vignette that makes the centre of the image brighter. I would usually achieve this effect by creating a new fill layer (new gradient fill), changing the style to radial, selecting reverse and change the blending mode to soft light at 45%. However, you can’t use a fill layer for a LUT – only an adjustment layer.

Is there anyway this effect can be achieved through an adjustment layer?

mvc – Is creating an entity in a database considered to be business logic?

According to my (perhaps incorrect) understanding business logic includes saving/updating entities in the database, as well as connecting with any 3rd party API’s or using services and should therefore reside in the Model in MVC architecture. The controller should call model methods, and is responsible for application-wide logic, like authentication, some global data validation and response to the client.

Because I’m developing in C# I read the official Microsoft article recommendation:

Business logic should reside in services and classes within the Models folder.

However, in another Microsoft sample .NET project creating an entity is done directly in the controller (PostTodoItem). So I’m wondering why isn’t this code inside the model itself? In my opinion the model should contain the method AddTodoItem which inserts a new todo item in the database. In theory adding an entity can be quite complex like validation, updating other models that’s why I thought this code shouldn’t reside directly in the controller.

8 – Creating a custom field programmatically with a link to the entity gives me an error

When creating a custom field with a reference to an entity, the following error appears. Here is the link of the article from where I took the example field https://www.lullabot.com/articles/extending-a-field-type-in-drupal-8.

The website encountered an unexpected error. Please try again later.
Error: Call to undefined method DrupalCoreFieldFieldItemList::referencedEntities() in DrupalCoreFieldPluginFieldFieldWidgetEntityReferenceAutocompleteWidget->formElement() (line 98 of core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/EntityReferenceAutocompleteWidget.php).
DrupalCoreFieldPluginFieldFieldWidgetEntityReferenceAutocompleteWidget->formElement(Object, 0, Array, Array, Object) (Line: 29)
Drupalorders_for_crmPluginFieldFieldWidgetOrderProductsFieldWidget->formElement(Object, 0, Array, Array, Object) (Line: 344)
DrupalCoreFieldWidgetBase->formSingleElement(Object, 0, Array, Array, Object) (Line: 211)
DrupalCoreFieldWidgetBase->formMultipleElements(Object, Array, Object) (Line: 113)
DrupalCoreFieldWidgetBase->form(Object, Array, Object) (Line: 287)
DrupalCoreFieldFieldItemList->defaultValuesForm(Array, Object) (Line: 127)
Drupalfield_uiFormFieldConfigEditForm->form(Array, Object) (Line: 149)
DrupalCoreEntityEntityForm->buildForm(Array, Object)
call_user_func_array(Array, Array) (Line: 532)
DrupalCoreFormFormBuilder->retrieveForm(‘field_config_edit_form’, Object) (Line: 278)
DrupalCoreFormFormBuilder->buildForm(Object, Object) (Line: 91)
DrupalCoreControllerFormController->getContentResult(Object, Object) (Line: 39)
Drupallayout_builderControllerLayoutBuilderHtmlEntityFormController->getContentResult(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
DrupalCoreEventSubscriberEarlyRenderingControllerWrapperSubscriber->DrupalCoreEventSubscriber{closure}() (Line: 573)
DrupalCoreRenderRenderer->executeInRenderContext(Object, Object) (Line: 124)
DrupalCoreEventSubscriberEarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
DrupalCoreEventSubscriberEarlyRenderingControllerWrapperSubscriber->DrupalCoreEventSubscriber{closure}() (Line: 151)
SymfonyComponentHttpKernelHttpKernel->handleRaw(Object, 1) (Line: 68)
SymfonyComponentHttpKernelHttpKernel->handle(Object, 1, 1) (Line: 57)
DrupalCoreStackMiddlewareSession->handle(Object, 1, 1) (Line: 47)
DrupalCoreStackMiddlewareKernelPreHandle->handle(Object, 1, 1) (Line: 106)
Drupalpage_cacheStackMiddlewarePageCache->pass(Object, 1, 1) (Line: 85)
Drupalpage_cacheStackMiddlewarePageCache->handle(Object, 1, 1) (Line: 47)
DrupalCoreStackMiddlewareReverseProxyMiddleware->handle(Object, 1, 1) (Line: 52)
DrupalCoreStackMiddlewareNegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
StackStackedHttpKernel->handle(Object, 1, 1) (Line: 708)
DrupalCoreDrupalKernel->handle(Object) (Line: 19)

php – Creating multiple tables with Plugin

I opened a new question, just to be sure. The former request has partly been resolved.
I got another question regarding creating tables for wordpress: Only one table is created (The first one), but the others not. Does somebody know why?

My Code now looks like this:

function artok_activate(){
    global $wpdb;
    require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
    $charset_collate                = $wpdb->get_charset_collate();
    $table_Veranstaltung            = $wpdb->prefix . 'Veranstaltung';
    $table_Personen                 = $wpdb->prefix . 'Personen';
    $table_Sponsor                  = $wpdb->prefix . 'Sponsor';
    $table_SponKunde                = $wpdb->prefix . 'SponKunde';
    
    if( $wpdb->get_var( "SHOW TABLES LIKE '$table_Veranstaltung'" ) != $table_Veranstaltung ) {
        $tableVer_Crea = 'CREATE TABLE ' . $table_Veranstaltung . '(
        ver_id int(11) NOT NULL AUTO_INCREMENT, 
        VeranstaltungName varchar(255), 
        PRIMARY KEY  (ver_id)
        )' . $charset_collate . ';';
        dbDelta( $tableVer_Crea );
        $success = empty($wpdb->last_error);
        
        return $success;
    }
    
    if( $wpdb->get_var( "SHOW TABLES LIKE '$table_Personen'" ) != $table_Personen ) {
        $tablePers_Crea = "CREATE TABLE " . $table_Personen . "(
        pers_id int(11) NOT NULL AUTO_INCREMENT, 
        Datum DATE, 
        Passwort varchar(255) UNIQUE, 
        Vorname varchar(255), 
        Nachname varchar(255), 
        Anrede varchar(255), 
        LoeschDatum DATE, 
        fkVer_id int(11), 
        FOREIGN KEY(fkVer_id) REFERENCES wp_Veranstaltung(Ver_id), 
        PRIMARY KEY  (pers_id)
        )" . $charset_collate . ";";
        
        dbDelta($tablePers_Crea);
        
        $success = empty($wpdb->last_error);
        
        return $success;
    }
    
    if( $wpdb->get_var( "SHOW TABLES LIKE '$table_Sponsor'" ) != $table_Sponsor) {
        $tableSp_Crea = "CREATE TABLE " . $table_Sponsor . "(
        sp_id int(11) NOT NULL AUTO_INCREMENT, 
        Code varchar(255), 
        Name varchar(255), 
        PRIMARY KEY  (sp_id)
        )" . $charset_collate . ";";
        dbDelta( $tableSp_Crea );
        $success = empty($wpdb->last_error);
        
        return $success;
    }
    
    if( $wpdb->get_var( "SHOW TABLES LIKE '$table_SponKunde'" ) != $table_SponKunde ) {
        $tableSpKu_Crea = "CREATE TABLE " . $table_SponKunde . "(
        fkPers_id int(11), 
        fkSp_id int(11), 
        FOREIGN KEY(fkPers_id) REFERENCES wp_Personen(pers_id), 
        FOREIGN KEY(fkSp_id) REFERENCES wp_Sponsor(sp_id)
        )" . $charset_collate . ";";
        dbDelta( $tableSpKu_Crea );
        $success = empty($wpdb->last_error);
        
        return $success;
    }
}   
    register_activation_hook( __FILE__, 'artok_activate' );

Problem with creating an instance of a class in SPFX(TypeScript/React)

I am facing a problem with creating an instance of a class in SPFX. I am not sure what I should put in as a parameter. The compiler complains on whatever I put as a parameter. Here is my code:

import { DefaultButton, values } from 'office-ui-fabric-react';
import * as React from 'react';
import { IReduxCounterProps } from '../components/IReduxCounterProps';
import Output from '../components/CounterOutput/Output';
import { ICounterState } from './ICounterState';

export default class Counter extends React.Component<IReduxCounterProps, ICounterState> {

    constructor(props: IReduxCounterProps) {
        super(props);
        this.state = {
            counter: 0
        }       
    }

    private counterOnIncrement() {
        console.log("Counter Increment");
        this.setState({ counter: this.state.counter + 1 });
        console.log(this.state.counter);        
    }

    private counterOnDecrement() {
        console.log("Counter Decrement");
        this.setState({ counter: this.state.counter - 1 });
    }
    
    public render() : React.ReactElement<IReduxCounterProps> {
        return(
            <div>
                <Output value={this.state.counter} description="test" />
                <DefaultButton text="Increment" onClick={() => this.counterOnIncrement()} />
                <DefaultButton text="Decrement" onClick={() => this.counterOnDecrement()} />
            </div>
        );
    }
}

const states = new Counter(1);
const test = new Counter("blavla");
const props = new Counter(props).state.counter;

IReduxCounterProps.ts:

export interface IReduxCounterProps {
  description: string;
  value: number;
}

ICounterState.ts:

export interface ICounterState {
    counter: number;
}

I am actually practicing some Redux on SPFx so what I am trying to do is access my state outside the Counter class in order to pass my state as a prop but the instance is requiring a parameter and complains on whatever I put as a parameter.

Here are my errors:

enter image description here

I would appreciate if someone could help me out with this issue.
Thanks in advance.

visualization – How can I change the Mathematica programming for creating a Venn Diagram?

I am working on using Venn diagram to explain logic and logical connections between sets. After coming upon these answers: Create a Venn Diagram,
How to plot Venn diagrams with Mathematica?,
which I found very helpful I was wondering if there is a way to convert the statement All Bananas are Tasty. (All Bananas are elements of Tasty or Bananas $iff$ Tasty) and All Apples are Tasty (Apples $iff$ Tasty) into a Venn diagram with three circles labeled?

The difference between this question and the questions above is I am wondering how to label an area of the Venn diagram, as well as how to instead of using $A_1$ and $A_2$ as values as explained in this good well-explained answer https://mathematica.stackexchange.com/a/2557/76873 by user https://mathematica.stackexchange.com/users/495/fjra use the values Bananas, Apples, and Tasty.

I am also wondering if there is a way to color the Venn diagram, possibly using PlotStyle or a graphics primitive?

google assistant – Problem creating a reminder with date/time in title

Using Android 9 on a Pixel 2, I can recreate this problem reliably.

Let’s say currently it is January 20. I prompt Google Assistant to start making a reminder for a certain date and time, such as:

“Remind me on February 8th at 6 pm”,

to which it replies:

“Okay, what’s the reminder?”

If I then want to the reminder text to say something like:
“Appointment tomorrow at noon”,
Google will interpret that as a new reminder set for January 21 at noon, instead of a reminder on February 8th at 6 pm saying “Appointment tomorrow at noon”.

This seems like a mistake, especially since Google specifically saved the date and time of the original request and prompted me just for the reminder text.

Has anyone found a solution to this? Many thanks.

boolean computation – How can I change the coding for creating a Venn Diagram?

I am working on using Venn diagram to explain logic and logical connections between sets. After coming upon these answers: Create a Venn Diagram,
How to plot Venn diagrams with Mathematica?,
which I found very helpful I was wondering if there is a way to convert the statement All Bananas are Tasty. (All Bananas are elements of Tasty or Bananas $iff$ Tasty) and All Apples are Tasty (Apples $iff$ Tasty) into a Venn diagram with three circles labeled?

The difference between this question and the questions above is I am wondering how to label an area of the Venn diagram, as well as how to instead of using $A_1$ and $A_2$ as values as explained in this answer https://mathematica.stackexchange.com/a/2557/76873 by user https://mathematica.stackexchange.com/users/495/fjra use the values Bananas, Apples, and Tasty.

I am also wondering if there is a way to color the Venn diagram, possibly using PlotStyle or a graphics primitive?