Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OSOE-338: Upgrade to Vue.js v3 in Lombiq.VueJs #122

Merged
merged 69 commits into from
Feb 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
a6b0b39
Refactor VueComponentApp.cshtml to use completely static script tag.
sarahelsaig Jan 27, 2024
a565ded
Rename vuejs to vuejs3. This will be used as a module name alias.
sarahelsaig Jan 27, 2024
0121d0f
Move the VueComponentApp's script into a js file.
sarahelsaig Jan 27, 2024
444d161
Remove the transformations from rollup-plugin-vue-sfc-orchard-core th…
sarahelsaig Jan 27, 2024
5a982d4
Merge remote-tracking branch 'origin/dev' into issue/OSOE-338
sarahelsaig Jan 30, 2024
92ee06d
remove orphaned variable
sarahelsaig Jan 31, 2024
3a2d2fa
Remove unnecessary vue package imports.
sarahelsaig Feb 1, 2024
11dde37
Add project root config files options for the vue build pipelines.
sarahelsaig Feb 1, 2024
4b7cbcf
upgrade to vue 3 in package.json
sarahelsaig Feb 1, 2024
ac7c72b
Register script resources.
sarahelsaig Feb 1, 2024
c837b75
Fix ESLint warnings.
sarahelsaig Feb 1, 2024
a4966ff
Remove all default rollup-alias usage.
sarahelsaig Feb 1, 2024
725c352
Add Vue3ContentSecurityPolicyProvider.
sarahelsaig Feb 1, 2024
63bd6b3
Don't use Common JS for SFC.
sarahelsaig Feb 1, 2024
85bcb58
Fix build error.
sarahelsaig Feb 1, 2024
855c2cf
Use importmap.
sarahelsaig Feb 2, 2024
a49cb3e
Add missing sample menu.
sarahelsaig Feb 4, 2024
c7c5466
Auto-guess area attribute.
sarahelsaig Feb 5, 2024
dd62663
Simplify /Lombiq.VueJs.Samples/QrCard/Index
sarahelsaig Feb 5, 2024
c344029
Fix bugs.
sarahelsaig Feb 5, 2024
e305e4e
use newer glob with built-in promise
sarahelsaig Feb 6, 2024
b4a0ad5
use vue-component-app.mjs
sarahelsaig Feb 12, 2024
b41520b
Use the new script-module extensions.
sarahelsaig Feb 13, 2024
9fdf331
readme
sarahelsaig Feb 14, 2024
5763337
Bug fixing.
sarahelsaig Feb 14, 2024
33bd2a7
Use hypenated GUID.
sarahelsaig Feb 14, 2024
b7395f0
Clean up and simplify vue app component.
sarahelsaig Feb 14, 2024
4d049a2
Fix importing bug. vue-component-app works now.
sarahelsaig Feb 14, 2024
afef028
Remove leftover debug code.
sarahelsaig Feb 14, 2024
0a1529a
Update Vue version.
sarahelsaig Feb 14, 2024
27188fd
Change how apps are globally stored.
sarahelsaig Feb 14, 2024
84c2191
Restore v-model functionality.
sarahelsaig Feb 15, 2024
65c5d2c
Update readme.
sarahelsaig Feb 15, 2024
6ced00e
partial v-model migration
sarahelsaig Feb 15, 2024
fcce36d
Support main ref.
sarahelsaig Feb 15, 2024
ac08e03
Fix v-model binding.
sarahelsaig Feb 15, 2024
1576e28
Update some comments.
sarahelsaig Feb 15, 2024
64c44fd
simplify vue app import
sarahelsaig Feb 16, 2024
673a1d9
Use ScriptModuleResourceFilter, remove now unnecessary shape.
sarahelsaig Feb 16, 2024
e3811af
VueComponentApp should be required by the correct tag helper.
sarahelsaig Feb 17, 2024
fbc6ed4
Update to the new v-model format.
sarahelsaig Feb 17, 2024
43f60c8
Get rid of ModelProperties, use component's "emit" to bind all availa…
sarahelsaig Feb 17, 2024
3af1209
Update /VueSfc/Index
sarahelsaig Feb 17, 2024
0991987
Less cshtml usings.
sarahelsaig Feb 17, 2024
0217671
Change the import name of vue components to the original module name.
sarahelsaig Feb 17, 2024
054339a
Update enahnced-list.
sarahelsaig Feb 17, 2024
84546ca
Fix CSP support for new vue 3 implementation.
sarahelsaig Feb 18, 2024
d0c7863
Temporarily comment out "app" tests.
sarahelsaig Feb 18, 2024
595851a
Spelling.
sarahelsaig Feb 18, 2024
ff4c01c
Code cleanup.
sarahelsaig Feb 18, 2024
5f67ed6
Fix static code analysis.
sarahelsaig Feb 18, 2024
8b966df
Remove app compiler.
sarahelsaig Feb 18, 2024
2a0dd7e
Update and clean up readme.
sarahelsaig Feb 18, 2024
ba58ceb
Fix readme?
sarahelsaig Feb 18, 2024
7cbdce6
Temporarily remove all ref comments.
sarahelsaig Feb 18, 2024
568eef5
Revert "Temporarily remove all ref comments."
sarahelsaig Feb 19, 2024
1ec8e95
Code cleanup.
sarahelsaig Feb 19, 2024
79cc5f6
Rename the app ID to "demoApp" for consistency.
sarahelsaig Feb 19, 2024
625f761
Add root propety because $el is broken.
sarahelsaig Feb 19, 2024
a171d28
Bug fixes.
sarahelsaig Feb 19, 2024
1b3b435
Update vue-pagination.
sarahelsaig Feb 19, 2024
91066d5
Update and fix qr-card.
sarahelsaig Feb 20, 2024
3b1fa17
ES code cleanup.
sarahelsaig Feb 20, 2024
4759d4f
ES code cleanup for real this time.
sarahelsaig Feb 20, 2024
998e9f2
Merge tag 'v3.0.2-alpha.3.osoe-751' into issue/OSOE-338-1.8
sarahelsaig Feb 20, 2024
ff097c1
Fix new analyzer warning.
sarahelsaig Feb 20, 2024
ddbb450
Merge remote-tracking branch 'origin/dev' into issue/OSOE-338
sarahelsaig Feb 21, 2024
625aba6
Fix NPM package version.
sarahelsaig Feb 21, 2024
4860175
Merge remote-tracking branch 'origin/dev' into issue/OSOE-338
sarahelsaig Feb 21, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 0 additions & 19 deletions Lombiq.VueJs.Samples/Assets/Apps/demo/components/demo-component.js

This file was deleted.

21 changes: 0 additions & 21 deletions Lombiq.VueJs.Samples/Assets/Apps/demo/main.js

This file was deleted.

13 changes: 0 additions & 13 deletions Lombiq.VueJs.Samples/Assets/Apps/demo/options.js

This file was deleted.

20 changes: 12 additions & 8 deletions Lombiq.VueJs.Samples/Assets/Scripts/VueComponents/demo-sfc.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
<!-- This is the template of the component. If you have IDE plugin for Vue.js, this format
affords you first-class Vue.js coding support. -->
<div class="DemoSfc__wrapper">
<select class="DemoSfc__select" @change="$emit('input', parseInt($event.target.value))">
<select class="DemoSfc__select" @change="$emit('update:model-value', parseInt($event.target.value))">
<!-- Note the bound "key" property - it must be unique and you should always include
it for performance reasons. Also the "value" binding is not strictly necessary
but can be useful for communicating value with external libraries, e.g. with
other JS scripts or during UI testing. -->
<option v-for="n in max"
:key="'demo-sfc-' + n"
:selected="value === n"
:selected="modelValue === n"
:value="n">
{{ n }}
</option>
Expand All @@ -31,11 +31,9 @@ export default {
// added during compilation.
// name: "demo-sfc",

// Here we declare a required and an optional property, both are validated to be numeric. The
// "value" here is a special property name, along with the "input" event name. They together
// make up the input and output part of the "v-model" directive you saw in the cshtml.
// Here we declare a required and an optional property, both are validated to be numeric.
props: {
value: {
modelValue: {
type: Number,
required: true,
},
Expand All @@ -45,11 +43,17 @@ export default {
},
},

// If you use the <vue-component-app> tag helper, the parent component automatically accepts matching "update:*"
// events for all provided model props. If you declare the "emits" option like below, then only those that are also
// listed here. This way props meant to be read-only won't get the same two-way binding and you won't see annoying
// warnings if you use the "Vue.js devtools" browser extension.
emits: ['update:model-value'],

// Computed properties are like getters, but they are cached and reactive. For example this
// one is only re-evaluated if self.value changes which triggers an update.
// one is only re-evaluated if self.modelValue changes which triggers an update.
computed: {
repeaterData(self) {
return Array.from({ length: self.value })
return Array.from({ length: self.modelValue })
.map((_, i) => `DemoRepeater__listItem_${i + 1}`);
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,22 @@
event handling boilerplate -->
<button type="button"
class="btn btn-primary"
:class="{ disabled: value <= 1 }"
@click.prevent="$emit('input', value - 1)">
:class="{ disabled: modelValue <= 1 }"
@click.prevent="$emit('update:model-value', modelValue - 1)">
[[ << ]]
</button>
<button v-for="page in max"
:key="'pager-' + page"
class="btn btn-primary"
:class="{ disabled: page === value }"
:class="{ disabled: page === modelValue }"
type="button"
@click.prevent="$emit('input', page)">
@click.prevent="$emit('update:model-value', page)">
{{ page }}
</button>
<button type="button"
class="btn btn-primary"
:class="{ disabled: value >= max }"
@click.prevent="$emit('input', value + 1)">
:class="{ disabled: modelValue >= max }"
@click.prevent="$emit('update:model-value', modelValue + 1)">
[[ >> ]]
</button>
</div>
Expand All @@ -28,7 +28,7 @@
<script>
export default {
props: {
value: {
modelValue: {
type: Number,
required: true,
},
Expand All @@ -37,6 +37,7 @@ export default {
required: true,
},
},
emits: ['update:model-value'],
};

// NEXT STATION: Assets/Scripts/VueComponents/enhancement-table-body.vue
Expand Down
34 changes: 21 additions & 13 deletions Lombiq.VueJs.Samples/Assets/Scripts/VueComponents/qr-card.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<div class="card">
<div class="card-body">
<h5 v-if="!loading && !error">[[ Scan code ]]</h5>
<qrcode-stream @decode="onDecode" @init="onInit" :track="paintOutline">
<qrcode-stream :track="paintOutline" @detect="onDetect" @init="onInit" @error="onError">
<loading-indicator v-if="loading">
[[ Loading ... ]]
</loading-indicator>
Expand Down Expand Up @@ -40,10 +40,19 @@
</template>

<script>
import { QrcodeStream } from '../../../node_modules/vue-qrcode-reader';
import { QrcodeStream } from 'vue-qrcode-reader';
import LoadingIndicator from './loading-indicator.vue';
import BusinessCard from './business-card.vue';

function tryParseJson(text) {
try {
return JSON.parse(text);
}
catch {
return {};
}
}

export default {
components: {
QrcodeStream,
Expand All @@ -65,18 +74,14 @@ export default {
};
},
methods: {
onDecode(result) {
const content = ((text) => {
try {
return JSON.parse(text);
}
catch {
return {};
}
})(result);
onDetect(detectedCodes) {
const json = detectedCodes
.filter((code) => code.format === 'qr_code' && code.rawValue)
.map((code) => code.rawValue)[0];
const cardId = tryParseJson(json).cardId;

this.cardId = content.cardId;
this.scanError = content.cardId ? '' : 'InvalidCard';
this.cardId = cardId;
this.scanError = cardId ? '' : 'InvalidCard';
},
async onInit(promise) {
this.loading = true;
Expand All @@ -91,6 +96,9 @@ export default {
this.loading = false;
}
},
onError(error) {
this.error = error.name;
},
paintOutline(detectedCodes, ctx) {
for (const detectedCode of detectedCodes) {
const [firstPoint, ...otherPoints] = detectedCode.cornerPoints;
Expand Down
2 changes: 0 additions & 2 deletions Lombiq.VueJs.Samples/Constants/ResourceNames.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ namespace Lombiq.VueJs.Samples.Constants;

public static class ResourceNames
{
public const string DemoApp = nameof(DemoApp);

public const string DemoSfc = "demo-sfc";
public const string DemoRepeater = "demo-repeater";

Expand Down
16 changes: 0 additions & 16 deletions Lombiq.VueJs.Samples/Controllers/VueAppController.cs

This file was deleted.

29 changes: 29 additions & 0 deletions Lombiq.VueJs.Samples/Navigation/VueJsNavigationProvider.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using Lombiq.HelpfulLibraries.OrchardCore.Navigation;
using Lombiq.VueJs.Samples.Controllers;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Localization;
using OrchardCore.Navigation;

namespace Lombiq.VueJs.Samples.Navigation;

public class VueJsNavigationProvider : MainMenuNavigationProviderBase
{
public VueJsNavigationProvider(
IHttpContextAccessor hca,
IStringLocalizer<VueJsNavigationProvider> stringLocalizer)
: base(hca, stringLocalizer)
{
}

protected override void Build(NavigationBuilder builder) =>
builder
.Add(T["Vue.js"], builder => builder
.Add(T["Vue Single File Component (SFC)"], itemBuilder => itemBuilder
.Action<VueSfcController>(_hca.HttpContext, controller => controller.Index()))
.Add(T["Standalone SFC with Tag Helper"], itemBuilder => itemBuilder
.Action<VueSfcController>(_hca.HttpContext, controller => controller.AppTagHelper()))
.Add(T["Progressive Enhancement"], itemBuilder => itemBuilder
.Action<VueSfcController>(_hca.HttpContext, controller => controller.EnhancedList(1)))
.Add(T["QR Card"], itemBuilder => itemBuilder
.Action<QrCardController>(_hca.HttpContext, controller => controller.Index())));
}
Original file line number Diff line number Diff line change
@@ -1,24 +1,16 @@
using Lombiq.VueJs.Extensions;
using Microsoft.Extensions.Options;
using OrchardCore.ResourceManagement;
using static Lombiq.VueJs.Samples.Constants.FeatureIds;
using static Lombiq.VueJs.Samples.Constants.ResourceNames;

namespace Lombiq.VueJs.Samples;

public class ResourceManagementOptionsConfiguration : IConfigureOptions<ResourceManagementOptions>
{
private const string Root = "~/" + Area;

private static readonly ResourceManifest _manifest = new();

static ResourceManagementOptionsConfiguration()
{
// This resource will be required for our demo Vue.js application.
_manifest
.DefineScript(DemoApp)
.SetUrl(Root + "/apps/demo.min.js", Root + "/apps/demo.js");

// This resource is not strictly required, but it tells the <vue-component> tag helper which other shapes it
// needs to import. As you can see we don't use SetUrl. Only SetDependencies is used if there are any.
_manifest
Expand Down
3 changes: 3 additions & 0 deletions Lombiq.VueJs.Samples/Startup.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
using Lombiq.HelpfulLibraries.Common.DependencyInjection;
using Lombiq.VueJs.Samples.Migrations;
using Lombiq.VueJs.Samples.Navigation;
using Lombiq.VueJs.Samples.TagHelpers;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
using OrchardCore.Data.Migration;
using OrchardCore.Modules;
using OrchardCore.Navigation;
using OrchardCore.ResourceManagement;

namespace Lombiq.VueJs.Samples;
Expand All @@ -15,5 +17,6 @@ public override void ConfigureServices(IServiceCollection services) =>
services.AddTransient<IConfigureOptions<ResourceManagementOptions>, ResourceManagementOptionsConfiguration>()
.AddScoped<IDataMigration, BusinessCardMigrations>()
.AddTagHelpers<QrCodeTagHelper>()
.AddScoped<INavigationProvider, VueJsNavigationProvider>()
.AddLazyInjectionSupport();
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
@using OrchardCore.ContentManagement

@foreach (var shape in Model)
{
@await DisplayAsync(shape)
Expand Down
14 changes: 3 additions & 11 deletions Lombiq.VueJs.Samples/Views/QrCard/Index.cshtml
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
@model Lombiq.VueJs.Samples.ViewModels.QrCardAppViewModel

<vue-component area="@FeatureIds.Area" name="@ResourceNames.QrCard" />
<div id="qrCardApp">
<qr-card api-url="@Model.ApiUrl">
</qr-card>
</div>

<script at="Foot" depends-on="@ResourceNames.QrCard">
window.app = new Vue({
el: '#qrCardApp',
});
</script>
@* This is the simplest use of the SFC app tag helper, the vue file is located in the same module as this view, so the
area attribute is automatically resolved. You only need the resource name and the model. *@
<vue-component-app name="@ResourceNames.QrCard" model="@Model" />
30 changes: 0 additions & 30 deletions Lombiq.VueJs.Samples/Views/VueApp/Index.cshtml

This file was deleted.

21 changes: 0 additions & 21 deletions Lombiq.VueJs.Samples/Views/VueComponents/Demo.Component.cshtml

This file was deleted.

Loading