Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[2.1] Варианты записи полей #391

Closed
tabuna opened this issue Dec 27, 2017 · 14 comments
Closed

[2.1] Варианты записи полей #391

tabuna opened this issue Dec 27, 2017 · 14 comments

Comments

@tabuna
Copy link
Member

tabuna commented Dec 27, 2017

Сейчас существует два вида записи полей, которые имеют свои плюсы и минусы:

В строчном виде

Плюсы:

  • Краткость

Минусы:

  • Нет возможность передать функции замыкания (вложенность)
  • Плохо смотрится при большом количестве значений
  • Нет подсветки и подсказок
return [
    'body' => 'tag:tag|wysiwyg|name:body|max:255|required|rows:10',
];

В массиве

Плюсы:

  • Есть возможность передавать функции замыкания (вложенность)
  • Хороший внешний вид при любом количестве аргументов

Минусы:

  • Файл становиться большим даже при малом количестве полей
  • Обязательно указывать значение, например см. "required"
  • Нет подсветки и подсказок
return [
    'body' => [
        'tag'      => 'wysiwyg',
        'name'     => 'body',
        'max'      => 255,
        'required' => true,
        'rows'     => 10,
    ],
];

Предложение:

Разрешить передавать классы

Плюсы:

  • Есть возможность передавать функции замыкания (вложенность)
  • Хороший внешний вид при любом количестве аргументов
  • Есть возможность базовой поддержки подсказок

Минусы:

  • Диссонанс с другими местами (Например в rules пишем строки, в grid массив)
return [
    'body' => Field::tag('wysiwyg')
        ->name('body')
        ->max(255)
        ->required()
        ->rows(10),
];

Что предпочтительнее:



@PSalador
Copy link
Member

Можно же добавить третий тип, и будет вместо двух - три типа.
А если один, то третий тип предпочтительней.

@Rendol
Copy link
Contributor

Rendol commented Dec 28, 2017

Поддерживаю @PSalador, вопрос только в потенциальной нагрузке дальнейшей поддержки.
На мой взгляд здесь только шаблон всё может сломать, т.е. явно использовать объект в шаблоне. Хотя можно такой объект создавать на основе тех же строки или массива.
Например так:

body' => Field::make('tag:wysiwyg|max:255')->rows(10)

аналогично с массивом:

body' => Field::make(['tag' => 'wysiwyg'])->max(255)->rows(10)

@ghost
Copy link

ghost commented Dec 28, 2017

Плагиатор!!)))

@tabuna
Copy link
Member Author

tabuna commented Dec 28, 2017

@Aios Cам меня критиковал и предлагал это раз таки 20 😂

@ghost
Copy link

ghost commented Dec 28, 2017

@tabuna "Не не хочу не буду бла бла бла" и все такое. а сейчас че?)

@tabuna
Copy link
Member Author

tabuna commented Dec 28, 2017

В церковь сходил )))

@Aios На самом деле, просто хочется подсказок, потому что начал забывать параметры

@tabuna
Copy link
Member Author

tabuna commented Jan 2, 2018

Итог:
Большинство за объект, но там же опять магия и подсказки будут только базовые.

Например:
name/class/checked/max/min и в т.д. То есть без специфичных для каждого поля (Размер изображения например)

Можно так же рассмотреть вариант, создания не абстрактного класса, а каждого:

Input::name('title');
Select::name('title');
TextArea::name('title');

@tabuna tabuna changed the title Варианты записи полей [2.1] Варианты записи полей Jan 5, 2018
@tabuna
Copy link
Member Author

tabuna commented Jan 5, 2018

Раз уж мы идёт по пути формирования классов над массивами, думаю имеет смысл тогда и изменить формирование записи таблицы, например:

Сейчас:

return [
    'appointment_time' => [
        'name'   => 'Time',
        'width'  => '200px',
        'action' => function ($appointment) {
            return $appointment->appointment_time->toDateString();
        },
    ],
    'appointment_type' => [
        'name'   => 'Type',
        'width'  => '200px',
        'action' => function ($appointment) {
            $types = config('appointment.types');
            $message = isset($types[$appointment->appointment_type]['text']) ? $types[$appointment->appointment_type]['text'] : '';
            return $message;
        },
    ],
    'doctor_notes'     => 'Notes',
];

Предложение:

return [
    TD::name('appointment_time')
        ->title('Time')
        ->width('200px')
        ->render(function ($appointment){
        return $appointment->appointment_time->toDateString();
    }),
    TD::name('appointment_type')
        ->title('Type')
        ->width('200px')
        ->render(function ($appointment){
        $types = config('appointment.types');
        $message = isset($types[$appointment->appointment_type]['text']) ? $types[$appointment->appointment_type]['text'] : '';
        return $message;
    }),
    TD::name('doctor_notes')
        ->title('Notes')
        ->width('200px'),
];

Выглядит конечно стрёмно.... Пожалуйста любые улучшения по этому поводу

@tabuna
Copy link
Member Author

tabuna commented Jan 6, 2018

Единственное, что приходит на ум, убрать title

return [
    TD::name('appointment_time','Time')
        ->width('200px')
        ->render(function ($appointment){
        return $appointment->appointment_time->toDateString();
    }),
    TD::name('appointment_type','Type')
        ->width('200px')
        ->render(function ($appointment){
        $types = config('appointment.types');
        $message = isset($types[$appointment->appointment_type]['text']) ? $types[$appointment->appointment_type]['text'] : '';
        return $message;
    }),
    TD::name('doctor_notes','Notes')
        ->width('200px'),
];

@PSalador
Copy link
Member

PSalador commented Jan 6, 2018

Да норм смотрится.

@ghost
Copy link

ghost commented Jan 7, 2018

Да норм смотрится 💯

tabuna added a commit that referenced this issue Jan 10, 2018
- Record fields as objects #391

### Deprecated
- Record string/array for fields. Use `Field::make`
@tabuna
Copy link
Member Author

tabuna commented Jan 10, 2018

Новый вид всех полей:

Всякие title,help,placeholder,max и т.п. соответственно не обязательны:)
можно наверное их убрать, оставить по одному, для примера.

Field::tag('input')
    ->type('text')
    ->name('place')
    ->max(255)
    ->required()
    ->title('Name Articles')
    ->help('Article title'),

Field::tag('wysiwyg')
    ->name('body')
    ->required()
    ->title('Name Articles')
    ->help('Article title'),

Field::tag('markdown')
    ->name('body2')
    ->required()
    ->title('Name Articles')
    ->help('Article title'),

Field::tag('picture')
    ->name('picture')
    ->width(500)
    ->height(300),

Field::tag('datetime')
    ->type('text')
    ->name('open')
    ->title('Opening date')
    ->help('The opening event will take place'),

Field::tag('checkbox')
    ->name('free')
    ->default(1)
    ->title('Free')
    ->placeholder('Event for free')
    ->help('Event for free'),

Field::tag('code')
    ->name('block')
    ->title('Code Block')
    ->help('Simple web editor'),

Field::tag('input')
    ->type('text')
    ->name('title')
    ->max(255)
    ->required()
    ->title('Article Title')
    ->help('SEO title'),

Field::tag('textarea')
    ->name('description')
    ->max(255)
    ->row(5)
    ->required()
    ->title('Short description'),

Field::tag('tags')
    ->name('keywords')
    ->title('Keywords')
    ->help('SEO keywords'),

Field::tag('robot')
    ->name('robot')
    ->title('Indexing')
    ->help('Allow search bots to index page'),

Field::tag('list')
    ->name('list')
    ->title('Dynamic list')
    ->help('Dynamic list'),

Field::tag('input')
    ->type('text')
    ->name('phone')
    ->mask('(999) 999-9999')
    ->title('Phone')
    ->help('Number Phone'),

Field::tag('place')
    ->name('place')
    ->title('Place')
    ->help('place for google maps'),

@Rendol
Copy link
Contributor

Rendol commented Jan 11, 2018

Хочу так:

    /**
     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
     */
    public function display()
    {
        return InputField::name('search')
            ->type("text")
            ->max(255)
            ->required()
            ->value($this->request->get('search', ''));
    }

И чтобы автокомплит работал:

/**
 * Class InputField
 *
 * @method static InputField name(string $name)
 * @method static InputField type(string $type)
 * @method static InputField max(integer $value)
 * @method static InputField required()
 * @method static InputField value(string $value)
 */
class InputField extends Field

Rendol added a commit to Rendol/platform that referenced this issue Jan 12, 2018
Rendol added a commit to Rendol/platform that referenced this issue Jan 13, 2018
tabuna added a commit that referenced this issue Jan 15, 2018
- "DIV" Layouts
- Select field
- "Show" key for admin menu

### Changed
- Record fields as objects #391

### Deprecated
- Record string/array for fields. Use `Field::make`

### Removed
- google analytics
- robot field
tabuna added a commit that referenced this issue Jan 17, 2018
- "DIV" Layouts
- "Select" field
- "Show" key for admin menu

### Changed
- Record fields as objects #391
- Demo "behaviors" are no longer published
- Access validation does not create multiple database queries

### Deprecated
- Record string/array for fields. Use `Field::make`

### Removed
- google analytics
- robot field
floristics pushed a commit to floristics/platform that referenced this issue Jan 19, 2018
- "DIV" Layouts
- Select field
- "Show" key for admin menu

### Changed
- Record fields as objects orchidsoftware#391

### Deprecated
- Record string/array for fields. Use `Field::make`

### Removed
- google analytics
- robot field
floristics pushed a commit to floristics/platform that referenced this issue Jan 19, 2018
- "DIV" Layouts
- "Select" field
- "Show" key for admin menu

### Changed
- Record fields as objects orchidsoftware#391
- Demo "behaviors" are no longer published
- Access validation does not create multiple database queries

### Deprecated
- Record string/array for fields. Use `Field::make`

### Removed
- google analytics
- robot field
@tabuna tabuna added this to the 2.1 Readiness milestone Jan 25, 2018
@tabuna
Copy link
Member Author

tabuna commented Feb 1, 2018

@Rendol Ты вроде какой то плагин делал для шторма? Сможешь генерировать подсказки из комментария выше??

Rendol added a commit to Rendol/platform that referenced this issue Feb 6, 2018
tabuna pushed a commit that referenced this issue Feb 6, 2018
Rendol added a commit to Rendol/platform that referenced this issue Feb 6, 2018
tabuna pushed a commit that referenced this issue Feb 6, 2018
* ref #391 - added virtual methods

* ref #391 - added virtual methods - to base Field
@tabuna tabuna closed this as completed Feb 6, 2018
tabuna added a commit that referenced this issue Apr 3, 2018
- Grouping items using Field::group
- TD::link and TD::linkPost
- Sorting capability for TD [437](#437)
- Property display for page
- Added ability to change the logo [354](#354)
- New command `orchid:install`

### Deprecated
- TD::name and TD::title use TD::set

### Changed
- Test migration pgsql to sqlite

### Fixed
- Require to required
- Hide the menu without children
- Deletes a file only if there are no more links [570](#570)
- Users and roles use screens [579](#579)

### Removed
- Font Awesome
- Bootstrap 3 appendix
- "Delete" button by default in the image field
- String record of parameters for building a form [391](#391)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

4 participants