Skip to content

Commit

Permalink
Use Ulid instead of Guid for better PERF
Browse files Browse the repository at this point in the history
  • Loading branch information
hishamco committed Oct 4, 2024
1 parent 027711f commit eb16274
Show file tree
Hide file tree
Showing 73 changed files with 440 additions and 321 deletions.
1 change: 1 addition & 0 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
<PackageVersion Include="StyleCop.Analyzers" Version="1.1.118" />
<PackageVersion Include="System.Linq.Async" Version="6.0.1" />
<PackageVersion Include="System.IO.Hashing" Version="8.0.0" />
<PackageVersion Include="Ulid" Version="1.3.4" />
<PackageVersion Include="xunit" Version="2.9.2" />
<PackageVersion Include="xunit.analyzers" Version="1.16.0" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.8.2" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ public async Task<ShellSettings> CreateTenantSettingsAsync(TenantSetupOptions se
shellSettings["TablePrefix"] = setupOptions.DatabaseTablePrefix;
shellSettings["Schema"] = setupOptions.DatabaseSchema;
shellSettings["DatabaseProvider"] = setupOptions.DatabaseProvider;
shellSettings["Secret"] = Guid.NewGuid().ToString();
shellSettings["Secret"] = Ulid.NewUlid().ToGuid().ToString();
shellSettings["RecipeName"] = setupOptions.RecipeName;
shellSettings["FeatureProfile"] = setupOptions.FeatureProfile;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,8 @@
<ProjectReference Include="..\..\OrchardCore\OrchardCore.Setup.Abstractions\OrchardCore.Setup.Abstractions.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Ulid" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -7,52 +7,84 @@
var selectedItems = JConvert.SerializeObject(Model.SelectedItems, JOptions.CamelCase);
var partName = Model.PartFieldDefinition.PartDefinition.Name;
var fieldName = Model.PartFieldDefinition.Name;
var editUrl = Url.RouteUrl(new { area = "OrchardCore.Contents", controller = "Admin", action = "Edit", contentItemId = "contentItemId", returnUrl = FullRequestPath });
var viewUrl = Url.RouteUrl(new { area = "OrchardCore.Contents", controller = "Admin", action = "Display", contentItemId = "contentItemId" });
var searchUrl = Url.RouteUrl(new { area = "OrchardCore.ContentFields", controller = "ContentPickerAdmin", action = "SearchContentItems", part = partName, field = fieldName });
var vueElementId = $"ContentPicker_{partName}_{fieldName}_{Guid.NewGuid().ToString("n")}";
var editUrl = Url.RouteUrl(new
{
area = "OrchardCore.Contents",
controller = "Admin",
action = "Edit",
contentItemId =
"contentItemId",
returnUrl = FullRequestPath
});
var viewUrl = Url.RouteUrl(new
{
area = "OrchardCore.Contents",
controller = "Admin",
action = "Display",
contentItemId
= "contentItemId"
});
var searchUrl = Url.RouteUrl(new
{
area = "OrchardCore.ContentFields",
controller = "ContentPickerAdmin",
action =
"SearchContentItems",
part = partName,
field = fieldName
});
var vueElementId = $"ContentPicker_{partName}_{fieldName}_{Ulid.NewUlid().ToGuid().ToString("n")}";
var multiple = settings.Multiple.ToString().ToLowerInvariant();
}

<script asp-name="vue-multiselect-wrapper" asp-src="~/OrchardCore.ContentFields/Scripts/vue-multiselect-wrapper.js" at="Foot" depends-on="vuejs, vue-multiselect, sortable, vuedraggable"></script>
<script asp-name="vue-multiselect-wrapper" asp-src="~/OrchardCore.ContentFields/Scripts/vue-multiselect-wrapper.js"
at="Foot" depends-on="vuejs, vue-multiselect, sortable, vuedraggable"></script>
<style asp-name="vue-multiselect" at="Foot"></style>

<div class="@Orchard.GetFieldWrapperClasses(Model.PartFieldDefinition)" id="@Html.IdFor(x => x.ContentItemIds)_FieldWrapper">
<label asp-for="ContentItemIds" class="@Orchard.GetLabelClasses(inputRequired: settings.Required)">@Model.PartFieldDefinition.DisplayName()</label>
<div class="@Orchard.GetFieldWrapperClasses(Model.PartFieldDefinition)"
id="@Html.IdFor(x => x.ContentItemIds)_FieldWrapper">
<label asp-for="ContentItemIds"
class="@Orchard.GetLabelClasses(inputRequired: settings.Required)">@Model.PartFieldDefinition.DisplayName()</label>
<div class="@Orchard.GetEndClasses()">
<div id="@vueElementId" class="vue-multiselect" data-part="@partName" data-field="@fieldName" data-editor-type="ContentPicker" data-selected-items="@selectedItems" data-edit-url="@editUrl" data-view-url="@viewUrl" data-search-url="@searchUrl" data-multiple="@multiple">
<div id="@vueElementId" class="vue-multiselect" data-part="@partName" data-field="@fieldName"
data-editor-type="ContentPicker" data-selected-items="@selectedItems" data-edit-url="@editUrl"
data-view-url="@viewUrl" data-search-url="@searchUrl" data-multiple="@multiple">

<ul class="mb-1 list-group w-lg-75 w-xxl-50 content-picker-default__list" v-show="arrayOfItems.length" v-cloak>
<ul class="mb-1 list-group w-lg-75 w-xxl-50 content-picker-default__list" v-show="arrayOfItems.length"
v-cloak>
<draggable v-model="arrayOfItems">
<li v-for="(item, i) in arrayOfItems"
class="cursor-move list-group-item content-picker-default__list-item d-flex align-items-start justify-content-between"
:key="item.id">
<div class="align-items-center align-self-center">
<a v-if="item.isClickable" :href="url(item)" target="_blank">
<span>{{ item.displayText }}</span> <span v-show="!item.hasPublished" class="text-muted small">(@T["Not published"])</span>
<span>{{ item.displayText }}</span> <span v-show="!item.hasPublished"
class="text-muted small">(@T["Not published"])</span>
</a>
<span v-else>
<span>{{ item.displayText }}</span> <span v-show="!item.hasPublished" class="text-muted small">(@T["Not published"])</span>
<span>{{ item.displayText }}</span> <span v-show="!item.hasPublished"
class="text-muted small">(@T["Not published"])</span>
</span>
</div>
<div class="btn-group btn-group-sm align-items-center" role="group">
<button v-on:click="remove(item)" type="button" class="btn btn-secondary content-picker-default__list-item__delete"><i class="fa-solid fa-trash fa-sm" aria-hidden="true"></i></button>
<button v-on:click="remove(item)" type="button"
class="btn btn-secondary content-picker-default__list-item__delete"><i
class="fa-solid fa-trash fa-sm" aria-hidden="true"></i></button>
</div>
</li>
</draggable>
</ul>

<div class="w-lg-75 w-xxl-50">
<input asp-for="ContentItemIds" type="hidden" v-model="selectedIds" />
<vue-multiselect v-model="value" :options="options" track-by="id"
label="displayText" placeholder="@T["Type to search"]"
@@search-change="asyncFind" @@select="onSelect"
:searchable="true" :close-on-select="true" :reset-after="true"
:show-labels="true" :hide-selected="@multiple"
:disabled="isDisabled"
select-label="@T["Select"]" deselect-label="@T["Remove"]">
<vue-multiselect v-model="value" :options="options" track-by="id" label="displayText"
placeholder="@T["Type to search"]" @@search-change="asyncFind" @@select="onSelect"
:searchable="true" :close-on-select="true" :reset-after="true" :show-labels="true"
:hide-selected="@multiple" :disabled="isDisabled" select-label="@T["Select"]"
deselect-label="@T["Remove"]">
<template slot="option" slot-scope="props">
<div v-cloak><span>{{ props.option.displayText }}</span><span class="small ms-2" v-show="!props.option.hasPublished">(@T["Not published"])</span></div>
<div v-cloak><span>{{ props.option.displayText }}</span><span class="small ms-2"
v-show="!props.option.hasPublished">(@T["Not published"])</span></div>
</template>
<template slot="noResult">
@T["No result found"]
Expand All @@ -66,4 +98,5 @@
</div>
</div>
</div>
<script at="Foot" depends-on="vue-multiselect-wrapper">initVueMultiselect(document.querySelector("#@vueElementId"))</script>
<script at="Foot"
depends-on="vue-multiselect-wrapper">initVueMultiselect(document.querySelector("#@vueElementId"))</script>
Original file line number Diff line number Diff line change
Expand Up @@ -11,44 +11,58 @@
var selectedItems = JConvert.SerializeObject(Model.SelectedItems, JOptions.CamelCase);
var partName = Model.PartFieldDefinition.PartDefinition.Name;
var fieldName = Model.PartFieldDefinition.Name;
var searchUrl = Url.RouteUrl(new { area = "OrchardCore.ContentFields", controller = "LocalizationSetContentPickerAdmin", action = "SearchLocalizationSets", part = partName, field = fieldName });
var vueElementId = $"LocalizedContentPicker_{partName}_{fieldName}_{Guid.NewGuid().ToString("n")}";
var searchUrl = Url.RouteUrl(new
{
area = "OrchardCore.ContentFields",
controller = "LocalizationSetContentPickerAdmin",
action = "SearchLocalizationSets",
part = partName,
field = fieldName
});
var vueElementId = $"LocalizedContentPicker_{partName}_{fieldName}_{Ulid.NewUlid().ToGuid().ToString("n")}";
var multiple = settings.Multiple.ToString().ToLowerInvariant();
}

<script asp-name="vue-multiselect-wrapper" asp-src="~/OrchardCore.ContentFields/Scripts/vue-multiselect-wrapper.js" at="Foot" depends-on="vuejs, vue-multiselect, sortable, vuedraggable"></script>
<script asp-name="vue-multiselect-wrapper" asp-src="~/OrchardCore.ContentFields/Scripts/vue-multiselect-wrapper.js"
at="Foot" depends-on="vuejs, vue-multiselect, sortable, vuedraggable"></script>
<style asp-name="vue-multiselect" at="Foot"></style>

<div class="@Orchard.GetFieldWrapperClasses(Model.PartFieldDefinition)" id="@Html.IdFor(x => x.LocalizationSets)_FieldWrapper">
<label asp-for="LocalizationSets" class="@Orchard.GetLabelClasses(inputRequired: settings.Required)">@Model.PartFieldDefinition.DisplayName()</label>
<div class="@Orchard.GetFieldWrapperClasses(Model.PartFieldDefinition)"
id="@Html.IdFor(x => x.LocalizationSets)_FieldWrapper">
<label asp-for="LocalizationSets"
class="@Orchard.GetLabelClasses(inputRequired: settings.Required)">@Model.PartFieldDefinition.DisplayName()</label>
<div class="@Orchard.GetEndClasses()">
<div id="@vueElementId" class="vue-multiselect" data-part="@partName" data-field="@fieldName" data-editor-type="LocalizationSetContentPicker" data-selected-items="@selectedItems" data-search-url="@searchUrl" data-multiple="@multiple">
<div id="@vueElementId" class="vue-multiselect" data-part="@partName" data-field="@fieldName"
data-editor-type="LocalizationSetContentPicker" data-selected-items="@selectedItems"
data-search-url="@searchUrl" data-multiple="@multiple">

<ul class="mb-1 list-group w-xl-50 content-picker-default__list" v-show="arrayOfItems.length" v-cloak>
<draggable v-model="arrayOfItems">
<li v-for="(item, i) in arrayOfItems"
class="cursor-move list-group-item content-picker-default__list-item d-flex align-items-start justify-content-between"
:key="item.id">
<div class="align-items-center align-self-center"><span>{{ item.displayText }}</span> <span v-show="!item.hasPublished" class="text-muted small">(@T["Not published"])</span></div>
<div class="align-items-center align-self-center"><span>{{ item.displayText }}</span> <span
v-show="!item.hasPublished" class="text-muted small">(@T["Not published"])</span></div>

<div class="btn-group btn-group-sm align-items-center" role="group">
<button v-on:click="remove(item)" type="button" class="btn btn-secondary content-picker-default__list-item__delete"><i class="fa-solid fa-trash fa-sm" aria-hidden="true"></i></button>
<button v-on:click="remove(item)" type="button"
class="btn btn-secondary content-picker-default__list-item__delete"><i
class="fa-solid fa-trash fa-sm" aria-hidden="true"></i></button>
</div>
</li>
</draggable>
</ul>

<div class="w-xl-50">
<input asp-for="LocalizationSets" type="hidden" v-model="selectedIds" />
<vue-multiselect v-model="value" :options="options" track-by="id"
label="displayText" placeholder="@T["Type to search"]"
@@search-change="asyncFind" @@select="onSelect"
:searchable="true" :close-on-select="true" :reset-after="true"
:show-labels="true" :hide-selected="@multiple"
:disabled="isDisabled"
select-label="@T["Select"]" deselect-label="@T["Remove"]">
<vue-multiselect v-model="value" :options="options" track-by="id" label="displayText"
placeholder="@T["Type to search"]" @@search-change="asyncFind" @@select="onSelect"
:searchable="true" :close-on-select="true" :reset-after="true" :show-labels="true"
:hide-selected="@multiple" :disabled="isDisabled" select-label="@T["Select"]"
deselect-label="@T["Remove"]">
<template slot="option" slot-scope="props">
<div v-cloak><span>{{ props.option.displayText }}</span><span class="small ms-2" v-show="!props.option.hasPublished">(@T["Not published"])</span></div>
<div v-cloak><span>{{ props.option.displayText }}</span><span class="small ms-2"
v-show="!props.option.hasPublished">(@T["Not published"])</span></div>
</template>
<template slot="noResult">
@T["No result found"]
Expand All @@ -62,4 +76,5 @@
</div>
</div>
</div>
<script at="Foot" depends-on="vue-multiselect-wrapper">initVueMultiselect(document.querySelector("#@vueElementId"))</script>
<script at="Foot"
depends-on="vue-multiselect-wrapper">initVueMultiselect(document.querySelector("#@vueElementId"))</script>
Original file line number Diff line number Diff line change
Expand Up @@ -19,32 +19,27 @@
var partName = Model.PartFieldDefinition.PartDefinition.Name;
var fieldName = Model.PartFieldDefinition.Name;

var vueElementId = $"MultiTextField-Picker_{partName}_{fieldName}_{Guid.NewGuid().ToString("n")}";
var vueElementId = $"MultiTextField-Picker_{partName}_{fieldName}_{Ulid.NewUlid().ToGuid().ToString("n")}";

var valuesKey = Html.NameFor(x => x.Values);
}

<script asp-src="~/OrchardCore.ContentFields/Scripts/vue-multiselect-multitextfieldpicker.min.js" debug-src="~/OrchardCore.ContentFields/Scripts/vue-multiselect-multitextfieldpicker.js" asp-name="multitextfieldpicker" at="Foot" depends-on="vuejs, vue-multiselect"></script>
<script asp-src="~/OrchardCore.ContentFields/Scripts/vue-multiselect-multitextfieldpicker.min.js"
debug-src="~/OrchardCore.ContentFields/Scripts/vue-multiselect-multitextfieldpicker.js"
asp-name="multitextfieldpicker" at="Foot" depends-on="vuejs, vue-multiselect"></script>
<style asp-name="vue-multiselect" at="Foot"></style>

<div class="@Orchard.GetFieldWrapperClasses(Model.PartFieldDefinition)" id="@Html.IdFor(x => x.Values)_FieldWrapper">
<label class="@Orchard.GetLabelClasses(inputRequired: settings.Required)">@Model.PartFieldDefinition.DisplayName()</label>
<label
class="@Orchard.GetLabelClasses(inputRequired: settings.Required)">@Model.PartFieldDefinition.DisplayName()</label>
<div class="@Orchard.GetEndClasses()">
<div id="@vueElementId" class="multitextfieldpicker" data-selectedvalues="@jSelectedValues" data-options="@jOptions" data-valueskey="@valuesKey">
<div id="@vueElementId" class="multitextfieldpicker" data-selectedvalues="@jSelectedValues"
data-options="@jOptions" data-valueskey="@valuesKey">
<div class="w-xl-50">
<input v-for="v in value" v-bind:name="valuesKey" v-bind:value="v.value" type="hidden" />
<vue-multiselect v-model="value"
placeholder="@T["Type to search"]"
select-label="@T["Select"]"
deselect-label="@T["Remove"]"
track-by="value"
label="name"
:options="options"
:multiple="true"
:show-labels="false"
:close-on-select="false"
:taggable="true"
tag-position="bottom">
<vue-multiselect v-model="value" placeholder="@T["Type to search"]" select-label="@T["Select"]"
deselect-label="@T["Remove"]" track-by="value" label="name" :options="options" :multiple="true"
:show-labels="false" :close-on-select="false" :taggable="true" tag-position="bottom">
<template slot="noOptions">
@T["No values found"]
</template>
Expand Down
Loading

0 comments on commit eb16274

Please sign in to comment.