TypiCMS / Base

Multilingual CMS built with Laravel.
MIT License
1.38k stars 400 forks source link

Extension for typiCMS #154

Open visermort opened 4 years ago

visermort commented 4 years ago

Hello! Extension https://packagist.org/packages/visermort/typimultiinput Is it useful do you think? How could it be improved?

sdebacker commented 4 years ago

Hello, thanks for sharing. I will try it when I have some time, but yes it's a good idea to make it a plugin.

ivarsmednis commented 4 years ago

Great work Visemort! Reusable repeatables are needed feature!

The only problem i got was getting error, when trying to add multiinput while creating item by clicking "Add" button. This is error i am getting https://jmp.sh/yS0T6bC

After item is created, it works nicely in edit mode (didn't try all the features yet).

Only thing that i see for improvement would be adding some visual/usability tweaks, like padding between fields and cards and maybe zebra colored rows? Try adding classes "table table-striped" to your "multiinput-body" table and bootstrap will take care automatically and will look nice!

Thanks for your work!

ivarsmednis commented 4 years ago

For more distinctive title (it is different section with subsections after all) you can add class="h4" to your multiinput-header -> label

then it will look like this https://jmp.sh/SMGlF2C

visermort commented 4 years ago

Thank You!

The only problem i got was getting error, when trying to add multiinput while creating item by clicking "Add" button. This is error i am getting https://jmp.sh/yS0T6bC

Can you describe when the error occurs. I'm trying to repeat it..

Try adding classes "table table-striped" to your "multiinput-body" table and bootstrap will take care automatically and will look nice!

Yes, a good idea

For more distinctive title (it is different section with subsections after all) you can add class="h4" to your multiinput-header -> label

Yes, may be h4 or h5. And one can put component to other tab on a form.

ivarsmednis commented 4 years ago

What i did was clean Typicms install, then created products module via artisan. then applied instruction from your readme. Here is my config

`<?php

define('MULTIINPUT_STATUS_WAITING', 0); define('MULTIINPUT_STATUS_ACTIVE', 1); define('MULTIINPUT_STATUS_DISABLE', 2);

$activeLabels = [ MULTIINPUT_STATUS_WAITING => "Waiting", MULTIINPUT_STATUS_ACTIVE => "Active", MULTIINPUT_STATUS_DISABLE => "Disable", ];

return [ //configName 'advantages' => [ "single-row" => false, "title" => "Advantages", "order" => [ "sort" => "ASC", "title" => "ASC" ], "columns" => [ [ "name" => "title", "title" => "Title", "type" => "Varchar", "translatable" => false, 'rules' => 'required|max:255', ],

        [
            "name" => "feature_image",
            "title" => "Feature Image",
            "type" => "Image"
        ],

        [
            "name" => "viewed",
            "title" => "Viewed",
            "type" => "Boolean",
            "translatable" => false
        ],

    ]
],

]; `

The error is only when inserting new row in products table. When i edit existing row - working nicely.

ivarsmednis commented 4 years ago

Its not a big problem since i could only show this field in admin, when editing a product record

visermort commented 4 years ago

Its not a big problem since i could only show this field in admin, when editing a product record

Error is fixed. It is need to update a model class (see update in manual) All wishes are realized.

ivarsmednis commented 4 years ago

Great work! Visemort, is it possible to make dropdown from related table items? Would be cool if i could pass some data from admin view (just like bootform selects).

visermort commented 4 years ago

Great work! Visemort, is it possible to make dropdown from related table items? Would be cool if i could pass some data from admin view (just like bootform selects).

Hi! Thank you! Now it is possible to update config from form. For example: {!! MultiInput::render('advantages', 'advantages', $model, ['columns' => ['templates' => ['items' => TypiCMS::templates()]]]) !!} and pass this array to ::publish() too. It would be fine if you will continue to use. May be there are some bugs I have not caught.

ivarsmednis commented 4 years ago

Visemort, everything is working nicely so far except one thing with dropdown. I can't get it to have selected item and admin dropdown is not remembering selected value. All works nicely if i define dropdown in config. But when i override it from view, it reneders dropdown options but none is selected.

it save to database correctly but not reading selected value.

here is the code (i also tried with your example templates code - same result).

    {!! MultiInput::render('data', 'pagelinks', $model, ['columns' => ['pages' => [
            'items' => Pages::all()->sortBy('title')->pluck('title', 'id')->toArray(),
            "name" => "pageId",
            "title" => "Pages",
            "type" => "Dropdown",
            "translatable" => false,
        ]]]) !!}
visermort commented 4 years ago

Visemort, everything is working nicely so far except one thing with dropdown. I can't get it to have selected item and admin dropdown is not remembering selected value. All works nicely if i define dropdown in config. But when i override it from view, it reneders dropdown options but none is selected.

it save to database correctly but not reading selected value.

here is the code (i also tried with your example templates code - same result).

    {!! MultiInput::render('data', 'pagelinks', $model, ['columns' => ['pages' => [
            'items' => Pages::all()->sortBy('title')->pluck('title', 'id')->toArray(),
            "name" => "pageId",
            "title" => "Pages",
            "type" => "Dropdown",
            "translatable" => false,
        ]]]) !!}

Hello. I tried {!! MultiInput::render('advantages', 'advantages', $model, ['columns' => ['pages' => [ 'items' => Pages::all()->sortBy('title')->pluck('title', 'id')->toArray(), "name" => "pages", "title" => "Pages", "type" => "Dropdown", ]]]) !!} and works well. When we override config in template, extension does array_merge_recursive(, ) In this case key "pages" must be the same with "name"=> "pages" as well. I will thange arrray_merge_recursive with other method.

ivarsmednis commented 4 years ago

You are right, this way its working perfect! Thank you!