Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
afsakar committed Sep 18, 2024
1 parent ebb2d29 commit e19ac01
Show file tree
Hide file tree
Showing 17 changed files with 336 additions and 155 deletions.
2 changes: 1 addition & 1 deletion .phpunit.cache/test-results
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"version":"pest_2.35.0","defects":[],"times":{"P\\Tests\\ExampleTest::__pest_evaluable_it_can_test":0.005,"P\\Tests\\ArchTest::__pest_evaluable_it_will_not_use_debugging_functions":0.144}}
{"version":"pest_2.35.0","defects":[],"times":{"P\\Tests\\ExampleTest::__pest_evaluable_it_can_test":0.001,"P\\Tests\\ArchTest::__pest_evaluable_it_will_not_use_debugging_functions":0.137}}
6 changes: 6 additions & 0 deletions config/filament-form-maker.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,10 @@
'extra_fields' => [
// 'field_name' => Field::class
],

'navigation_icons' => [
'builder' => 'tabler-forms',
'collections' => 'tabler-category',
'form_data' => 'tabler-file-text',
],
];
17 changes: 16 additions & 1 deletion resources/lang/en/form-maker.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,20 @@

// translations for Afsakar/FormMaker
return [
//
'navigation_group' => 'Form Management',

'resources' => [
'builder' => [
'model_label' => 'Form Builder',
'plural_model_label' => 'Form Builders',
],
'collections' => [
'model_label' => 'Form Collection',
'plural_model_label' => 'Form Collections',
],
'form_data' => [
'model_label' => 'Form Data',
'plural_model_label' => 'Form Data',
],
],
];
105 changes: 104 additions & 1 deletion resources/lang/tr/form-maker.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,108 @@

// translations for Afsakar/FormMaker
return [
//
'navigation_group' => 'Form Yönetimi',

'resources' => [
'builder' => [
'section_title' => 'Form Bilgileri',
'model_label' => 'Form Oluşturucu',
'plural_model_label' => 'Form Oluşturucular',
'inputs' => [
'name' => 'Adı',
],
'options' => [
'title' => 'Form Ayarları',
'description' => 'Daha Fazla Form Ayarları',
'notification_name' => 'Bildirim Adı',
'background_color' => 'Arka Plan Rengi',
'mail_notifications' => 'Mail Bildirimleri',
'user_emails' => 'Kullanıcı E-postaları',
'user_emails_hint' => 'Forum\'un doldurulduktan sonra iletilmesini istediğiniz kullanıcıları seçiniz.',
'static_fields' => [
'full_span' => 'Tam Genişlik',
'placeholder' => 'Placeholder',
'notification_name' => 'Bildirim Adı',
'is_required' => 'Zorunlu Alan',
'hidden_label' => 'Gizli Etiket',
'field_id' => 'Alan ID',
'html_id' => 'HTML ID',
'column_span' => 'Sütun Genişliği',
'helper_text' => 'Yardımcı Metin',
],
'select_field' => [
'title' => 'Seçim Kutusu Ayarları',
'is_multiple' => 'Çoklu Seçim',
'is_searchable' => 'Arama Yapılabilir',
'data_source' => 'Veri Kaynağı',
],
'checkbox_radio_field' => [
'title' => 'Onay Kutusu / Seçim Düğmesi Ayarları',
'data_source' => 'Veri Kaynağı',
'one_column' => 'Tek Sütun',
'two_columns' => 'İki Sütun',
'three_columns' => 'Üç Sütun',
'four_columns' => 'Dört Sütun',
],
'text_field' => [
'title' => 'Metin Alanı Ayarları',
'field_type' => 'Alan Tipi',
'types' => [
'text' => 'Metin',
'email' => 'E-posta',
'url' => 'URL',
'number' => 'Sayı',
],
'max_value' => 'Maksimum Değer',
'min_value' => 'Minimum Değer',
],
'file_field' => [
'title' => 'Dosya Alanı Ayarları',
'max_size' => 'Maksimum Dosya Sayısı',
'hint' => 'KB cinsinden',
'accepted_file_types' => 'İzin Verilen Uzantılar',
'image' => 'Resim',
],
'visibility' => [
'title' => 'Koşullu Görünürlük',
'active' => 'Koşullu Görünürlük Aktif',
'fieldId' => 'Koşul Bağlanacak Alan',
'values' => 'Görünürlük Değeri',
'values_helper_text' => 'Eğer herhangi bir değer seçildiği takdirde görünür olmasını istiyorsanız bu alanı boş bırakın.',
],
],
'sections' => [
'title' => 'Bölümler',
'count' => 'Bölüm Sayısı',
'add_action_label' => 'Bölüm Ekle',
'new_section_label' => 'Yeni Bölüm',
'inputs' => [
'title' => 'Başlık',
'columns' => 'Sütun Sayısı',
'columns_hint' => 'Bölümdeki sütun sayısı',
],
],
'fields' => [
'title' => 'Alanlar',
'add_action_label' => 'Alan Ekle',
'new_field_label' => 'Yeni Alan',
'options' => [
'title' => 'Alan Ayarları',
'description' => 'Daha Fazla Alan Ayarları',
],
'inputs' => [
'name' => 'Alan Adı',
'type' => 'Alan Tipi',
],
],
],
'collections' => [
'model_label' => 'Form Koleksiyonu',
'plural_model_label' => 'Form Koleksiyonları',
],
'form_data' => [
'model_label' => 'Form Verileri',
'plural_model_label' => 'Form Verileri',
],
],
];
5 changes: 4 additions & 1 deletion src/Fields/Classes/Checkbox.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public static function make(FormBuilderField $field): Forms\Components\Field
{
return Forms\Components\CheckboxList::make(data_get($field, 'options.fieldId'))
->label(data_get($field, 'name'))
->hiddenLabel(data_get($field, 'options.hidden_label', false))
->columnSpan([
'xs' => 1,
'sm' => 1,
Expand All @@ -29,6 +30,7 @@ public static function make(FormBuilderField $field): Forms\Components\Field
'xl' => data_get($field, 'options.columns', 2),
'default' => data_get($field, 'options.columns', 2),
])
->reactive()
->gridDirection('row')
->id(data_get($field, 'options.htmlId'))
->options(self::getOptions($field))
Expand All @@ -47,8 +49,9 @@ public static function make(FormBuilderField $field): Forms\Components\Field
return $get($fieldId);
}

return $value === $get($fieldId);
return in_array($get($fieldId), $value);
})
->helperText(data_get($field, 'options.helper_text', null))
->required(data_get($field, 'options.is_required', false));
}

Expand Down
9 changes: 6 additions & 3 deletions src/Fields/Classes/DatePicker.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ class DatePicker extends Field
public static function make(FormBuilderField $field): Forms\Components\Field
{
return Forms\Components\DatePicker::make(data_get($field, 'options.fieldId'))
->hiddenLabel()
->placeholder(data_get($field, 'options.is_required', false) ? data_get($field, 'name') . ' *' : data_get($field, 'name'))
->label(data_get($field, 'name'))
->hiddenLabel(data_get($field, 'options.hidden_label', false))
->placeholder(data_get($field, 'options.hidden_label', false) ? (data_get($field, 'options.placeholder') !== null ? data_get($field, 'options.placeholder') : data_get($field, 'name')) : null)
->columnSpan([
'xs' => 1,
'sm' => 1,
Expand All @@ -21,6 +22,7 @@ public static function make(FormBuilderField $field): Forms\Components\Field
'xl' => data_get($field, 'options.column_span', 1),
'default' => data_get($field, 'options.column_span', 1),
])
->reactive()
->id(data_get($field, 'options.htmlId'))
->closeOnDateSelection()
->format('d F Y')
Expand All @@ -41,8 +43,9 @@ public static function make(FormBuilderField $field): Forms\Components\Field
return $get($fieldId);
}

return $value === $get($fieldId);
return in_array($get($fieldId), $value);
})
->helperText(data_get($field, 'options.helper_text', null))
->required(data_get($field, 'options.is_required', false));
}
}
6 changes: 5 additions & 1 deletion src/Fields/Classes/FileInput.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ public static function make(FormBuilderField $field): Forms\Components\Field
{
return Forms\Components\FileUpload::make(data_get($field, 'options.fieldId'))
->label(data_get($field, 'name'))
->hiddenLabel(data_get($field, 'options.hidden_label', false))
->placeholder(data_get($field, 'options.hidden_label', false) ? (data_get($field, 'options.placeholder') !== null ? data_get($field, 'options.placeholder') : data_get($field, 'name')) : null)
->columnSpan([
'xs' => 1,
'sm' => 1,
Expand All @@ -22,6 +24,7 @@ public static function make(FormBuilderField $field): Forms\Components\Field
'xl' => data_get($field, 'options.column_span', 1),
'default' => data_get($field, 'options.column_span', 1),
])
->reactive()
->id(data_get($field, 'options.htmlId'))
->acceptedFileTypes(data_get($field, 'options.accepted_file_types') ?? ['application/pdf'])
->maxSize(data_get($field, 'options.max_size', 5120))
Expand All @@ -42,8 +45,9 @@ public static function make(FormBuilderField $field): Forms\Components\Field
return $get($fieldId);
}

return $value === $get($fieldId);
return in_array($get($fieldId), $value);
})
->helperText(data_get($field, 'options.helper_text', null))
->required(data_get($field, 'options.is_required', false));
}
}
9 changes: 6 additions & 3 deletions src/Fields/Classes/PhoneInput.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ class PhoneInput extends Field
public static function make(FormBuilderField $field): Forms\Components\Field
{
return BasePhoneInput::make(data_get($field, 'options.fieldId'))
->hiddenLabel()
->placeholder(data_get($field, 'options.is_required', false) ? data_get($field, 'name') . ' *' : data_get($field, 'name'))
->label(data_get($field, 'name'))
->hiddenLabel(data_get($field, 'options.hidden_label', false))
->placeholder(data_get($field, 'options.hidden_label', false) ? (data_get($field, 'options.placeholder') !== null ? data_get($field, 'options.placeholder') : data_get($field, 'name')) : null)
->columnSpan([
'xs' => 1,
'sm' => 1,
Expand All @@ -24,6 +25,7 @@ public static function make(FormBuilderField $field): Forms\Components\Field
'xl' => data_get($field, 'options.column_span', 1),
'default' => data_get($field, 'options.column_span', 1),
])
->reactive()
->id(data_get($field, 'options.htmlId'))
->visible(function ($get) use ($field) {
$visibilty = data_get($field, 'options.visibility');
Expand All @@ -40,8 +42,9 @@ public static function make(FormBuilderField $field): Forms\Components\Field
return $get($fieldId);
}

return $value === $get($fieldId);
return in_array($get($fieldId), $value);
})
->helperText(data_get($field, 'options.helper_text', null))
->required(data_get($field, 'options.is_required', false));
}
}
4 changes: 3 additions & 1 deletion src/Fields/Classes/Radio.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public static function make(FormBuilderField $field): Forms\Components\Field
'xl' => data_get($field, 'options.columns', 2),
'default' => data_get($field, 'options.columns', 2),
])
->reactive()
->gridDirection('row')
->id(data_get($field, 'options.htmlId'))
->options(self::getOptions($field))
Expand All @@ -47,8 +48,9 @@ public static function make(FormBuilderField $field): Forms\Components\Field
return $get($fieldId);
}

return $value === $get($fieldId);
return in_array($get($fieldId), $value);
})
->helperText(data_get($field, 'options.helper_text', null))
->required(data_get($field, 'options.is_required', false));
}

Expand Down
8 changes: 5 additions & 3 deletions src/Fields/Classes/Select.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ class Select extends Field
public static function make(FormBuilderField $field): Forms\Components\Field
{
return Forms\Components\Select::make(data_get($field, 'options.fieldId'))
->hiddenLabel()
->placeholder(data_get($field, 'options.is_required', false) ? data_get($field, 'name') . ' *' : data_get($field, 'name'))
->label(data_get($field, 'name'))
->hiddenLabel(data_get($field, 'options.hidden_label', false))
->placeholder(data_get($field, 'options.hidden_label', false) ? (data_get($field, 'options.placeholder') !== null ? data_get($field, 'options.placeholder') : data_get($field, 'name')) : null)
->columnSpan([
'xs' => 1,
'sm' => 1,
Expand Down Expand Up @@ -43,8 +44,9 @@ public static function make(FormBuilderField $field): Forms\Components\Field
return $get($fieldId);
}

return $value === $get($fieldId);
return in_array($get($fieldId), $value);
})
->helperText(data_get($field, 'options.helper_text', null))
->required(data_get($field, 'options.is_required', false));
}

Expand Down
9 changes: 6 additions & 3 deletions src/Fields/Classes/TextInput.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ class TextInput extends Field
public static function make(FormBuilderField $field): Forms\Components\Field
{
return Forms\Components\TextInput::make(data_get($field, 'options.fieldId'))
->hiddenLabel()
->label(data_get($field, 'name'))
->hiddenLabel(data_get($field, 'options.hidden_label', false))
->placeholder(data_get($field, 'options.hidden_label', false) ? (data_get($field, 'options.placeholder') !== null ? data_get($field, 'options.placeholder') : data_get($field, 'name')) : null)
->type(data_get($field, 'options.field_type', 'text'))
->placeholder(data_get($field, 'options.is_required', false) ? data_get($field, 'name') . ' *' : data_get($field, 'name'))
->columnSpan([
'xs' => 1,
'sm' => 1,
Expand All @@ -22,6 +23,7 @@ public static function make(FormBuilderField $field): Forms\Components\Field
'xl' => data_get($field, 'options.column_span', 1),
'default' => data_get($field, 'options.column_span', 1),
])
->reactive()
->id(data_get($field, 'options.htmlId'))
->maxValue(data_get($field, 'options.max_value', null))
->minValue(data_get($field, 'options.min_value', null))
Expand All @@ -40,8 +42,9 @@ public static function make(FormBuilderField $field): Forms\Components\Field
return $get($fieldId);
}

return $value === $get($fieldId);
return in_array($get($fieldId), $value);
})
->helperText(data_get($field, 'options.helper_text', null))
->required(data_get($field, 'options.is_required', false));
}
}
9 changes: 6 additions & 3 deletions src/Fields/Classes/Textarea.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ class Textarea extends Field
public static function make(FormBuilderField $field): \Filament\Forms\Components\Field
{
return Forms\Components\Textarea::make(data_get($field, 'options.fieldId'))
->hiddenLabel()
->placeholder(data_get($field, 'options.is_required', false) ? data_get($field, 'name') . ' *' : data_get($field, 'name'))
->label(data_get($field, 'name'))
->hiddenLabel(data_get($field, 'options.hidden_label', false))
->placeholder(data_get($field, 'options.hidden_label', false) ? (data_get($field, 'options.placeholder') !== null ? data_get($field, 'options.placeholder') : data_get($field, 'name')) : null)
->columnSpan([
'xs' => 1,
'sm' => 1,
Expand All @@ -21,6 +22,7 @@ public static function make(FormBuilderField $field): \Filament\Forms\Components
'xl' => data_get($field, 'options.column_span', 1),
'default' => data_get($field, 'options.column_span', 1),
])
->reactive()
->autosize()
->id(data_get($field, 'options.htmlId'))
->visible(function ($get) use ($field) {
Expand All @@ -38,8 +40,9 @@ public static function make(FormBuilderField $field): \Filament\Forms\Components
return $get($fieldId);
}

return $value === $get($fieldId);
return in_array($get($fieldId), $value);
})
->helperText(data_get($field, 'options.helper_text', null))
->required(data_get($field, 'options.is_required', false));
}
}
Loading

0 comments on commit e19ac01

Please sign in to comment.