Skip to content

Commit

Permalink
Merge branch '2.1' into 2.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryan Thompson committed Feb 1, 2017
2 parents 16dc6cb + fe17db2 commit 6c15bb5
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 1 deletion.
11 changes: 11 additions & 0 deletions resources/config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,15 @@
'min' => 1,
],
],
'mode' => [
'required' => true,
'type' => 'anomaly.field_type.select',
'config' => [
'options' => [
'default' => 'anomaly.field_type.files::config.mode.option.default',
'select' => 'anomaly.field_type.files::config.mode.option.select',
'upload' => 'anomaly.field_type.files::config.mode.option.upload',
],
],
],
];
9 changes: 9 additions & 0 deletions resources/lang/en/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,13 @@
'label' => 'Maximum Selections',
'instructions' => 'Enter the maximum number of allowed selections.',
],
'mode' => [
'name' => 'Input Mode',
'instructions' => 'How should users provide file input?',
'option' => [
'default' => 'Upload and/or select files.',
'select' => 'Select files only.',
'upload' => 'Upload files only.',
],
],
];
4 changes: 4 additions & 0 deletions resources/views/input.twig
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
{{ asset_add('scripts.js', 'anomaly.field_type.files::js/jquery-sortable.js') }}
{{ asset_add('scripts.js', 'anomaly.field_type.files::js/input.js') }}

{% if field_type.config.mode in ['default', 'select'] %}
<a data-toggle="modal" data-target="#{{ field_type.field_name }}-modal" class="btn btn-info btn-xs" href="{{ url('streams/files-field_type/index/' ~ field_type.config_key) }}">{{ trans('anomaly.field_type.file::button.select_file') }}</a>
{% endif %}

{% if field_type.config.mode in ['default', 'upload'] %}
<a data-toggle="modal" data-target="#{{ field_type.field_name }}-modal" {% if field_type.config.folders|length == 1 %} href="{{ url('streams/files-field_type/upload/' ~ field_type.config.folders|first) }}" {% else %} href="{{ url('streams/files-field_type/choose/' ~ field_type.config_key) }}" {% endif %} class="btn btn-success btn-xs">{{ trans('anomaly.field_type.file::button.upload') }}</a>
{% endif %}

<input type="hidden" name="{{ field_type.input_name }}" value="{{ field_type.ids|join(',') }}" {{ html_attributes(field_type.attributes) }} {{ field_type.disabled ? 'disabled' }} {{ field_type.readonly ? 'readonly' }}>

Expand Down
4 changes: 3 additions & 1 deletion src/FilesFieldType.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ class FilesFieldType extends FieldType
*
* @var array
*/
protected $config = [];
protected $config = [
'mode' => 'default',
];

/**
* The cache repository.
Expand Down

0 comments on commit 6c15bb5

Please sign in to comment.