Merge pull request #216 from j122j/config-types
Change input type based on configuration type
This commit is contained in:
commit
4f953474cd
2 changed files with 13 additions and 4 deletions
|
@ -112,7 +112,7 @@ class ConfigurationController extends Controller
|
|||
|
||||
return datatables($query)
|
||||
->addColumn('actions', function (Configuration $configuration) {
|
||||
return '<button data-content="Edit" data-toggle="popover" data-trigger="hover" data-placement="top" onclick="configuration.parse(\'' . $configuration->key . '\',\'' . $configuration->value . '\')" data-content="Edit" data-trigger="hover" data-toggle="tooltip" class="btn btn-sm btn-info mr-1"><i class="fas fa-pen"></i></button> ';
|
||||
return '<button data-content="Edit" data-toggle="popover" data-trigger="hover" data-placement="top" onclick="configuration.parse(\'' . $configuration->key . '\',\'' . $configuration->value . '\',\'' . $configuration->type . '\')" data-content="Edit" data-trigger="hover" data-toggle="tooltip" class="btn btn-sm btn-info mr-1"><i class="fas fa-pen"></i></button> ';
|
||||
})
|
||||
->editColumn('created_at', function (Configuration $configuration) {
|
||||
return $configuration->created_at ? $configuration->created_at->diffForHumans() : '';
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
<i class="fa fa-cog"></i>
|
||||
</div>
|
||||
</div>
|
||||
<input id="value" name="value" type="text" class="form-control" required="required">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@ -37,16 +36,26 @@
|
|||
<button type="submit" class="btn btn-primary">Save</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
window.configuration = {
|
||||
parse(key, value){
|
||||
parse(key, value, type) {
|
||||
$('#keyLabel').html(key)
|
||||
$('#key').val(key)
|
||||
$('#value').remove();
|
||||
if (type === 'integer') {
|
||||
$('.input-group').append('<input id="value" name="value" type="number" class="form-control" required="required">')
|
||||
} else if (type === 'boolean') {
|
||||
$('.input-group').append('<select id="value" name="value" class="form-control" required=required>' +
|
||||
'<option value="true">true</option>' +
|
||||
'<option value="false">false</option>' +
|
||||
'</select>')
|
||||
} else if (type === 'string') {
|
||||
$('.input-group').append('<input id="value" name="value" type="text" class="form-control" required="required">')
|
||||
}
|
||||
$('#value').val(value)
|
||||
$('#editConfigurationModel').modal('show')
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue