fix configuration creation in picker

This commit is contained in:
2020-06-10 13:41:48 +02:00
parent d76a86aadc
commit 55bf577f7b
4 changed files with 35 additions and 12 deletions
+21
View File
@@ -74,6 +74,21 @@ namespace zero.Core.Api
}
/// <inheritdoc />
public async Task<Dictionary<string, T>> GetByIds<T>(params string[] ids) where T : IZeroIdEntity
{
using (IAsyncDocumentSession session = Raven.OpenAsyncSession())
{
IList<T> items = await session.Query<T>()
.Scope(Scope)
.Where(x => x.Id.In(ids))
.ToListAsync();
return ids.ToDictionary(x => x, x => items.FirstOrDefault(item => item.Id == x));
}
}
/// <inheritdoc />
public async Task<EntityResult<T>> SaveModel<T>(T model, IValidator validator = null) where T : IZeroIdEntity
@@ -223,6 +238,12 @@ namespace zero.Core.Api
/// </summary>
Task<T> GetById<T>(string id) where T : IZeroIdEntity;
/// <summary>
/// Get entities by ids.
/// If the requested entity is an IAppAwareEntity it will only return entities for the currently selected app + shared app
/// </summary>
Task<Dictionary<string, T>> GetByIds<T>(params string[] ids) where T : IZeroIdEntity;
/// <summary>
/// Updates or creates an entity with an optional validator
/// </summary>
@@ -149,9 +149,13 @@
watch: {
config()
{
this.buildConfig();
config: {
deep: true,
handler()
{
this.buildConfig();
this.loaded = false;
}
},
value(val)
{
@@ -212,18 +216,12 @@
},
mounted()
{
this.load();
},
methods: {
buildConfig()
{
var config = JSON.parse(JSON.stringify(defaultConfig));
this.configuration = _extend(defaultConfig, this.config);
this.configuration = _extend(JSON.parse(JSON.stringify(config)), this.config);
this.configuration.search = _extend(config.search, this.config.search || {});
this.configuration.addButton = _extend(config.addButton, this.config.addButton || {});
this.configuration.preview = _extend(config.preview, this.config.preview || {});
@@ -234,6 +232,10 @@
overlayOpened()
{
if (!this.loaded)
{
this.load();
}
if (this.configuration.search.focus)
{
this.$nextTick(() => this.$refs.search.focus());
@@ -141,7 +141,7 @@
height: 100%;
align-items: center;
position: relative;
color: var(--color-fg-mid);
color: var(--color-fg);
&:hover
{
@@ -302,7 +302,7 @@ button::-moz-focus-inner
display: inline-flex;
justify-content: center;
align-items: center;
padding: 5px;
padding: 10px;
}
}