1
0
mirror of https://github.com/garraflavatra/rolens.git synced 2025-01-18 13:07:58 +00:00

Form bugfixes

This commit is contained in:
Romein van Buren 2023-01-29 20:16:31 +01:00
parent 99108121c3
commit dc5b12ee0d
Signed by: romein
GPG Key ID: 0EFF8478ADDF6C49
6 changed files with 13 additions and 14 deletions

View File

@ -42,7 +42,7 @@ export function input(node, { autofocus, type, onValid, onInvalid, mandatory } =
return checkInteger() || checkNumberBoundaries(uint64);
case 'string':
if (mandatory && (node.value == '')) {
if (mandatory && (!node.value)) {
return 'This field cannot empty';
}
return false;

View File

@ -8,7 +8,7 @@
export let valid = false;
const validity = {};
$: valid = Object.values(validity).every(v => !!v);
$: valid = Object.values(validity).every(v => v !== false);
const iconMap = {
string: 'text',
@ -49,7 +49,7 @@
</div>
<div class="input">
<FormInput {column} bind:value={keypathProxy[column.key]} bind:valid={validity[column.key]} />
<button type="button" class="btn" title="Reset value" on:click={() => reset(column.key)} disabled={!keypathProxy[column.key]}>
<button type="button" class="btn" title="Reset value" on:click={() => reset(column.key)} disabled={keypathProxy[column.key] === undefined}>
<Icon name="reload" />
</button>
</div>
@ -89,6 +89,7 @@
font-size: 10px;
padding: 3px 5px;
font-weight: 600;
line-height: 1;
}
.tag.invalid {
background-color: rgba(255, 80, 80, 0.3);

View File

@ -35,7 +35,7 @@
database: collection.dbKey,
collection: collection.key,
type: 'table',
columns: [ { key: '_id', showInTable: true, inputType: 'string' } ],
columns: [ { key: '_id', showInTable: true, inputType: 'objectid', mandatory: true } ],
};
activeViewKey = newViewKey;
}

View File

@ -19,15 +19,14 @@
$: viewsForCollection = views.forCollection(collection.hostKey, collection.dbKey, collection.key);
$: oppositeViewType = viewType === 'table' ? 'form' : 'table';
$: if (collection.viewKey !== 'list') {
json = JSON.stringify(newItems, undefined, 2);
}
async function insert() {
if (collection.viewKey === 'list') {
insertedIds = await InsertItems(collection.hostKey, collection.dbKey, collection.key, json);
}
else {
insertedIds = await InsertItems(collection.hostKey, collection.dbKey, collection.key, JSON.stringify(newItems));
if (insertedIds) {
newItems = [];
}
insertedIds = await InsertItems(collection.hostKey, collection.dbKey, collection.key, json);
if ((collection.viewKey === 'list') && insertedIds) {
newItems = [];
}
}

View File

@ -115,6 +115,7 @@
{ label: 'Drop database…', fn: () => dropDatabase(dbKey) },
{ separator: true },
{ label: 'New database…', fn: () => dispatch('newDatabase') },
{ label: 'New collection…', fn: () => dispatch('newCollection') },
],
})),
menu: [

View File

@ -48,7 +48,6 @@
busy.start();
$connections[activeHostKey].databases[newDb.name] = { collections: {} };
newDb = undefined;
await hostTree.reload();
busy.end();
}
@ -73,7 +72,6 @@
busy.start();
$connections[activeHostKey].databases[activeDbKey].collections[newColl.name] = {};
newColl = undefined;
await hostTree.reload();
busy.end();
}