15 changes: 13 additions & 2 deletions modules/Cockpit/assets/components/field-tags.tag
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,18 @@

if (opts.autocomplete) {

UIkit.autocomplete(this.refs.autocomplete, {source: opts.autocomplete});
var _source = opts.autocomplete;

if (Array.isArray(opts.autocomplete) && opts.autocomplete.length && !opts.autocomplete[0].value) {

_source = [];

opts.autocomplete.forEach(function(val) {
_source.push({value:val})
})
}

UIkit.autocomplete(this.refs.autocomplete, {source: _source, minLength: opts.minLength || 1});
}

App.$(this.root).on({
Expand All @@ -47,7 +58,7 @@

var value = e.type=='keydown' ? $this.refs.input.value : data.value;

if (e.type=='keydown' && e.keyCode != 13) {
if (e.type=='keydown' && e.keyCode != 13 && e.keyCode != 188) {
return;
}

Expand Down
16 changes: 14 additions & 2 deletions modules/Cockpit/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,20 @@

$path = trim(str_replace(rtrim($this->app->filestorage->getUrl('assets://'), '/'), '', $src), '/');

if ($this->app->filestorage->has('assets://'.$path)) {
$asset = $this->app->storage->findOne('cockpit/assets', ['path' => "/{$path}"]);
try {

if ($this->app->filestorage->has('assets://'.$path)) {

$asset = $this->app->storage->findOne('cockpit/assets', ['path' => "/{$path}"]);

if (!$asset) {
$asset = ['path' => "/{$path}"];
}
}

} catch (\Exception $e) {

return $src;
}

} elseif (!preg_match('/\.(png|jpg|jpeg|gif)$/i', $src)) {
Expand Down
2 changes: 1 addition & 1 deletion modules/Collections/Controller/Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ public function entry($collection, $id = null) {

$view = 'collections:views/entry.php';

if ($override = $this->app->path('#config:collections/'.$collection['name'].'views/entry.php')) {
if ($override = $this->app->path('#config:collections/'.$collection['name'].'/views/entry.php')) {
$view = $override;
}

Expand Down
29 changes: 26 additions & 3 deletions modules/Collections/Controller/RestApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,27 @@ public function get($collection=null) {
$options['fieldsFilter'] = $fieldsFilter;
}

if (isset($options["sort"])) {
if ($sort) {

foreach ($sort as $key => &$value) {
$options["sort"][$key]= intval($value);
}
}

$entries = $this->module('collections')->find($collection['name'], $options);
$count = count($entries);
$isSortable = $collection['sortable'] ?? false;

// sort by custom order if collection is sortable
if (!$sort && $isSortable && $count) {

$entries = $this->helper('utils')->buildTree($entries, [
'parent_id_column_name' => '_pid',
'children_key_name' => 'children',
'id_column_name' => '_id',
'sort_column_name' => '_o'
]);
}

// return only entries array - due to legacy
if ((boolean) $this->param('simple', false)) {
Expand Down Expand Up @@ -89,7 +102,7 @@ public function get($collection=null) {
return [
'fields' => $fields,
'entries' => $entries,
'total' => (!$skip && !$limit) ? count($entries) : $this->module('collections')->count($collection['name'], $filter ? $filter : [])
'total' => (!$skip && !$limit) ? $count : $this->module('collections')->count($collection['name'], $filter ? $filter : [])
];

return $entries;
Expand All @@ -112,7 +125,17 @@ public function save($collection=null) {
return $this->stop('{"error": "Unauthorized"}', 401);
}

$data['_by'] = $this->module('cockpit')->getUser('_id');
$userId = $this->module('cockpit')->getUser('_id');

if (isset($data[0])) {

foreach ($data as &$entry) {
$entry['_by'] = $userId;
}

} else {
$data['_by'] = $userId;
}

$data = $this->module('collections')->save($collection, $data);

Expand Down
2 changes: 1 addition & 1 deletion modules/Singletons/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
$app->on('admin.init', function() {


if (!$this->module('cockpit')->getGroupRights('singleton') && !$this->module('singletons')->getSingletonInGroup()) {
if (!$this->module('cockpit')->getGroupRights('singletons') && !$this->module('singletons')->getSingletonInGroup()) {

$this->bind('/singletons/*', function() {
return $this('admin')->denyRequest();
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cockpit-next",
"version": "0.6.0",
"version": "0.6.1",
"license": "MIT",
"scripts": {
"build": "npm run build-style && npm run build-components",
Expand Down