output countries in settings

This commit is contained in:
2020-04-13 12:41:22 +02:00
parent 47a5742d49
commit 2ebf7edc9b
9 changed files with 170 additions and 12 deletions
+8 -3
View File
@@ -1,4 +1,5 @@
using Raven.Client.Documents;
using Raven.Client.Documents.Linq;
using Raven.Client.Documents.Session;
using System.Collections.Generic;
using System.Threading.Tasks;
@@ -18,11 +19,15 @@ namespace zero.Core.Api
/// <inheritdoc />
public async Task<IList<Country>> GetAll()
public async Task<IList<Country>> GetAll(string languageId)
{
using (IAsyncDocumentSession session = Raven.OpenAsyncSession())
{
return await session.Query<Country>().ToListAsync();
return await session.Query<Country>()
.Where(x => x.LanguageId == languageId)
.OrderByDescending(x => x.IsPreferred)
.ThenBy(x => x.Name)
.ToListAsync();
}
}
}
@@ -33,6 +38,6 @@ namespace zero.Core.Api
/// <summary>
/// Get all available countries
/// </summary>
Task<IList<Country>> GetAll();
Task<IList<Country>> GetAll(string languageId);
}
}
+1 -1
View File
@@ -168,7 +168,7 @@ namespace zero.Core.Api
{
CreatedDate = DateTimeOffset.Now,
IsActive = true,
Alias = Alias.Generate(model.AppName),
Alias = Alias.Generate(country.Key),
LanguageId = languageISO,
Code = country.Key,
Name = country.Value
@@ -1,7 +1,7 @@
<template>
<div class="ui-table-filter">
<ui-button type="light" label="Filter" caret="down" />
<ui-search />
<ui-button v-if="filter" type="light" label="Filter" caret="down" />
<ui-search v-if="search" />
</div>
</template>
@@ -11,7 +11,14 @@
name: 'uiTableFilter',
props: {
filter: {
type: Boolean,
default: true
},
search: {
type: Boolean,
default: true
}
},
data: () => ({
+6 -5
View File
@@ -2,7 +2,7 @@
<div class="ui-table-outer">
<div class="ui-table">
<header class="ui-table-row ui-table-head">
<div v-for="column in columns" class="ui-table-cell" :table-field="column.field">
<div v-for="column in columns" class="ui-table-cell" :table-field="column.field" :style="column.flex">
{{ column.label | localize }}
<button :disabled="!column.canSort" @click="sort(column)" type="button" class="ui-table-sort" :class="filter.orderBy == column.field ? 'sort-' + (filter.isDescending ? 'desc' : 'asc') : null">
<i class="arrow arrow-down"></i>
@@ -11,7 +11,7 @@
</header>
<div class="ui-table-row" v-for="item in items">
<div v-for="column in columns" class="ui-table-cell" :table-field="column.field" v-table-value="{ item, column }"></div>
<div v-for="column in columns" class="ui-table-cell" :style="column.flex" :table-field="column.field" v-table-value="{ item, column }"></div>
</div>
</div>
@@ -108,9 +108,10 @@
}
this.columns.push(_extend(data, {
label: column.label || (this.configuration.labelPrefix + key),
label: data.label || (this.configuration.labelPrefix + key),
field: key,
canSort: typeof column.sort === 'boolean' ? column.sort : this.configuration.sort
canSort: typeof data.sort === 'boolean' ? data.sort : this.configuration.sort,
flex: data.width ? { 'flex': '0 1 ' + data.width + 'px' } : {}
}));
});
},
@@ -226,7 +227,7 @@
{
display: inline-block;
align-items: center;
flex: 1 0 5%;
flex: 1 1 5%;
position: relative;
text-align: left;
padding: 18px 20px 17px 20px;
+101
View File
@@ -0,0 +1,101 @@
<template>
<div class="lists">
<ui-header-bar title="Countries" :on-back="goBack">
<ui-button type="light" label="Add" icon="fth-plus" />
<ui-table-filter :filter="false" />
</ui-header-bar>
<div class="ui-blank-box">
<ui-table :config="tableConfig" />
</div>
</div>
</template>
<script>
import CountriesApi from 'zero/resources/countries.js';
export default {
data: () => ({
tableConfig: {}
}),
created()
{
this.tableConfig = {
labelPrefix: '@country.fields.',
sort: false,
columns: {
name: 'text',
code: 'text',
isActive: {
as: 'bool',
label: '@ui.active',
width: 200
}
//status: {
// as: 'html',
// render: item => '<b>' + item.status + '</b>'
//}
},
items: CountriesApi.getAll
};
},
methods: {
getItems(config)
{
return new Promise(resolve =>
{
resolve([
{
no: 1,
createdDate: '2020-03-05T10:17:25.229+01:00',
username: 'Tobias Klika',
price: 70.90,
status: 'Open',
isPublished: true
},
{
no: 2,
createdDate: '2020-03-05T10:17:25.229+01:00',
username: 'Fox Tales',
price: 12.95,
status: 'Processing',
isPublished: true
},
{
no: 3,
createdDate: '2020-03-07T17:17:25.229+01:00',
username: 'Christian Klika, das ist mein Name und der könnte noch viel länger sein',
price: 123.00,
status: 'Completed'
},
{
no: 1,
createdDate: '2020-03-05T10:17:25.229+01:00',
username: 'Tobias Klika',
price: 70.90,
status: 'Open',
isPublished: true
},
{
no: 2,
createdDate: '2020-03-05T10:17:25.229+01:00',
username: 'Fox Tales',
price: 12.95,
status: 'Processing'
},
]);
});
},
goBack()
{
this.$router.go(-1);
}
}
}
</script>
+10
View File
@@ -0,0 +1,10 @@
import Axios from 'axios';
export default {
// get all countries
getAll()
{
return Axios.get('countries/getAll').then(res => Promise.resolve(res.data));
}
};
@@ -0,0 +1,25 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using System.Threading.Tasks;
using zero.Core;
using zero.Core.Api;
namespace zero.Web.Controllers
{
[AllowAnonymous]
public class CountriesController : BackofficeController
{
private ICountriesApi Api { get; set; }
public CountriesController(IZeroConfiguration config, ICountriesApi api) : base(config)
{
Api = api;
}
public async Task<IActionResult> GetAll()
{
return Json(await Api.GetAll("en-US"));
}
}
}
@@ -10,6 +10,7 @@
"close": "Close",
"confirm": "Confirm",
"createdDate": "Created at",
"active": "Published",
"pagination": {
"xofy": "Page {x} of {y}",
"next": "Next page",
@@ -135,5 +136,12 @@
"history_text": "View page editing history"
}
}
},
"country": {
"fields": {
"name": "Name",
"code": "ISO"
}
}
}
+1
View File
@@ -139,6 +139,7 @@ namespace zero.Web
services.AddTransient<IPageTreeApi, PageTreeApi>();
services.AddTransient<ISettingsApi, SettingsApi>();
services.AddTransient<IAuthenticationApi, AuthenticationApi>();
services.AddTransient<ICountriesApi, CountriesApi>();
}
/// <summary>