WizardSeeder MaxHeight ve MaxWidth hesaplaması
This commit is contained in:
parent
646f558d1a
commit
acb06587c4
3 changed files with 57 additions and 12 deletions
|
|
@ -31,7 +31,6 @@ public class WizardDataSeeder : IDataSeedContributor, ITransientDependency
|
||||||
private readonly IRepository<LanguageText, Guid> _repoLangText;
|
private readonly IRepository<LanguageText, Guid> _repoLangText;
|
||||||
private readonly IRepository<PermissionGroupDefinitionRecord, Guid> _repoPermGroup;
|
private readonly IRepository<PermissionGroupDefinitionRecord, Guid> _repoPermGroup;
|
||||||
private readonly IRepository<PermissionDefinitionRecord, Guid> _repoPerm;
|
private readonly IRepository<PermissionDefinitionRecord, Guid> _repoPerm;
|
||||||
private readonly IPermissionGrantRepository _permissionGrantRepository;
|
|
||||||
private readonly IRepository<Menu, Guid> _repoMenu;
|
private readonly IRepository<Menu, Guid> _repoMenu;
|
||||||
private readonly IRepository<DataSource, Guid> _repoDataSource;
|
private readonly IRepository<DataSource, Guid> _repoDataSource;
|
||||||
private readonly IRepository<ListForm, Guid> _repoListForm;
|
private readonly IRepository<ListForm, Guid> _repoListForm;
|
||||||
|
|
@ -47,7 +46,6 @@ public class WizardDataSeeder : IDataSeedContributor, ITransientDependency
|
||||||
IRepository<LanguageText, Guid> repoLangText,
|
IRepository<LanguageText, Guid> repoLangText,
|
||||||
IRepository<PermissionGroupDefinitionRecord, Guid> repoPermGroup,
|
IRepository<PermissionGroupDefinitionRecord, Guid> repoPermGroup,
|
||||||
IRepository<PermissionDefinitionRecord, Guid> repoPerm,
|
IRepository<PermissionDefinitionRecord, Guid> repoPerm,
|
||||||
IPermissionGrantRepository permissionGrantRepository,
|
|
||||||
IRepository<Menu, Guid> repoMenu,
|
IRepository<Menu, Guid> repoMenu,
|
||||||
IRepository<DataSource, Guid> repoDataSource,
|
IRepository<DataSource, Guid> repoDataSource,
|
||||||
IRepository<ListForm, Guid> repoListForm,
|
IRepository<ListForm, Guid> repoListForm,
|
||||||
|
|
@ -59,7 +57,6 @@ public class WizardDataSeeder : IDataSeedContributor, ITransientDependency
|
||||||
_repoLangText = repoLangText;
|
_repoLangText = repoLangText;
|
||||||
_repoPermGroup = repoPermGroup;
|
_repoPermGroup = repoPermGroup;
|
||||||
_repoPerm = repoPerm;
|
_repoPerm = repoPerm;
|
||||||
_permissionGrantRepository = permissionGrantRepository;
|
|
||||||
_repoMenu = repoMenu;
|
_repoMenu = repoMenu;
|
||||||
_repoDataSource = repoDataSource;
|
_repoDataSource = repoDataSource;
|
||||||
_repoListForm = repoListForm;
|
_repoListForm = repoListForm;
|
||||||
|
|
@ -337,6 +334,56 @@ public class WizardDataSeeder : IDataSeedContributor, ITransientDependency
|
||||||
await _repoListFormWorkflow.DeleteManyAsync(existingWorkflowCriteria, autoSave: true);
|
await _repoListFormWorkflow.DeleteManyAsync(existingWorkflowCriteria, autoSave: true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// EditingForm'da required olan alanları tespit et, ValidationRuleJson eklemek için
|
||||||
|
var editingFormFieldNames = input.Groups
|
||||||
|
.SelectMany(g => g.Items)
|
||||||
|
.Where(i => i.IncludeInEditingForm && i.DataField != input.KeyFieldName)
|
||||||
|
.Select(i => new { FieldName = i.DataField, Isrequired = i.IsRequired })
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
// Heigth ve Width hesaplama
|
||||||
|
var groupLayouts = input.Groups
|
||||||
|
.Select(g =>
|
||||||
|
{
|
||||||
|
var items = g.Items
|
||||||
|
.Where(i => i.IncludeInEditingForm && i.DataField != input.KeyFieldName)
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
var columnCount = g.ColCount;
|
||||||
|
|
||||||
|
if (columnCount <= 0)
|
||||||
|
columnCount = 1;
|
||||||
|
|
||||||
|
// 3 kolonu geçmesin
|
||||||
|
columnCount = Math.Min(columnCount, WizardConsts.EditFormMaxColumnCount);
|
||||||
|
|
||||||
|
// Örneğin 4 item / 3 kolon = 2 satır
|
||||||
|
var rowCount = (int)Math.Ceiling(items.Count / (double)columnCount);
|
||||||
|
|
||||||
|
return new
|
||||||
|
{
|
||||||
|
Group = g,
|
||||||
|
Items = items,
|
||||||
|
ColumnCount = columnCount,
|
||||||
|
RowCount = rowCount
|
||||||
|
};
|
||||||
|
})
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
// Form genelinde kullanılacak kolon sayısı
|
||||||
|
var formColumnCount = groupLayouts.Any()
|
||||||
|
? groupLayouts.Max(x => x.ColumnCount)
|
||||||
|
: 1;
|
||||||
|
|
||||||
|
// Width hesabı
|
||||||
|
var formWidth = (WizardConsts.EditFormMaxWidth / WizardConsts.EditFormMaxColumnCount) * formColumnCount;
|
||||||
|
|
||||||
|
// Toplam satır sayısı
|
||||||
|
var totalRowCount = groupLayouts.Sum(x => x.RowCount);
|
||||||
|
|
||||||
|
// Height hesabı
|
||||||
|
var formHeight = WizardConsts.EditFormHeightDefault + (totalRowCount * WizardConsts.EditFormHeightByRow);
|
||||||
|
|
||||||
// ListForm
|
// ListForm
|
||||||
await _repoListForm.InsertAsync(new ListForm
|
await _repoListForm.InsertAsync(new ListForm
|
||||||
{
|
{
|
||||||
|
|
@ -376,20 +423,13 @@ public class WizardDataSeeder : IDataSeedContributor, ITransientDependency
|
||||||
? WizardConsts.DefaultInsertFieldsDefaultValueJson(input.KeyFieldDbSourceType)
|
? WizardConsts.DefaultInsertFieldsDefaultValueJson(input.KeyFieldDbSourceType)
|
||||||
: WizardConsts.DefaultFieldsJsonOnlyId(input.KeyFieldDbSourceType),
|
: WizardConsts.DefaultFieldsJsonOnlyId(input.KeyFieldDbSourceType),
|
||||||
PagerOptionJson = WizardConsts.DefaultPagerOptionJson,
|
PagerOptionJson = WizardConsts.DefaultPagerOptionJson,
|
||||||
EditingOptionJson = WizardConsts.DefaultEditingOptionJson(titleLangKey, 600, 500, input.AllowDeleting, input.AllowAdding, input.AllowUpdating, input.ConfirmDelete, false, input.AllowDetail),
|
EditingOptionJson = WizardConsts.DefaultEditingOptionJson(titleLangKey, formWidth, formHeight, input.AllowDeleting, input.AllowAdding, input.AllowUpdating, input.ConfirmDelete, false, input.AllowDetail),
|
||||||
EditingFormJson = editingFormDtos.Count > 0 ? JsonSerializer.Serialize(editingFormDtos) : null,
|
EditingFormJson = editingFormDtos.Count > 0 ? JsonSerializer.Serialize(editingFormDtos) : null,
|
||||||
SubFormsJson = input.SubForms.Count > 0 ? JsonSerializer.Serialize(input.SubForms) : null,
|
SubFormsJson = input.SubForms.Count > 0 ? JsonSerializer.Serialize(input.SubForms) : null,
|
||||||
WidgetsJson = input.Widgets.Count > 0 ? JsonSerializer.Serialize(input.Widgets) : null,
|
WidgetsJson = input.Widgets.Count > 0 ? JsonSerializer.Serialize(input.Widgets) : null,
|
||||||
WorkflowJson = HasWorkflow(input.Workflow, input.WorkflowCriteria) ? JsonSerializer.Serialize(input.Workflow) : null,
|
WorkflowJson = HasWorkflow(input.Workflow, input.WorkflowCriteria) ? JsonSerializer.Serialize(input.Workflow) : null,
|
||||||
}, autoSave: true);
|
}, autoSave: true);
|
||||||
|
|
||||||
// EditingForm'da required olan alanları tespit et, ValidationRuleJson eklemek için
|
|
||||||
var editingFormFieldNames = input.Groups
|
|
||||||
.SelectMany(g => g.Items)
|
|
||||||
.Where(i => i.IncludeInEditingForm && i.DataField != input.KeyFieldName)
|
|
||||||
.Select(i => new { FieldName = i.DataField, Isrequired = i.IsRequired })
|
|
||||||
.ToList();
|
|
||||||
|
|
||||||
// ListFormFields
|
// ListFormFields
|
||||||
var fieldOrder = 0;
|
var fieldOrder = 0;
|
||||||
foreach (var group in input.Groups)
|
foreach (var group in input.Groups)
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,11 @@ using System.Globalization;
|
||||||
|
|
||||||
public static class WizardConsts
|
public static class WizardConsts
|
||||||
{
|
{
|
||||||
|
public static int EditFormMaxWidth => 1200;
|
||||||
|
public static int EditFormMaxColumnCount = 3;
|
||||||
|
public static int EditFormHeightDefault => 125;
|
||||||
|
public static int EditFormHeightByRow => 75;
|
||||||
|
|
||||||
public static string WizardKey(string code) => $"{Prefix.App}.Wizard.{code}";
|
public static string WizardKey(string code) => $"{Prefix.App}.Wizard.{code}";
|
||||||
public static string WizardKeyTitle(string code) => $"{WizardKey(code)}.Title";
|
public static string WizardKeyTitle(string code) => $"{WizardKey(code)}.Title";
|
||||||
public static string WizardKeyDesc(string code) => $"{WizardKey(code)}.Desc";
|
public static string WizardKeyDesc(string code) => $"{WizardKey(code)}.Desc";
|
||||||
|
|
|
||||||
|
|
@ -667,7 +667,7 @@ function GroupCard({
|
||||||
<span className="text-xs text-gray-400">
|
<span className="text-xs text-gray-400">
|
||||||
{translate('::ListForms.Wizard.Step3.Cols') || 'Cols:'}
|
{translate('::ListForms.Wizard.Step3.Cols') || 'Cols:'}
|
||||||
</span>
|
</span>
|
||||||
{[1, 2, 3, 4].map((n) => (
|
{[1, 2, 3].map((n) => (
|
||||||
<button
|
<button
|
||||||
key={n}
|
key={n}
|
||||||
type="button"
|
type="button"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue