From b5a62af8bc9a015d4cc9638b5eb71378e1e2db59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jarda=20Kot=C4=9B=C5=A1ovec?= Date: Tue, 14 Jan 2025 12:37:28 +0100 Subject: [PATCH 1/5] pkp/pkp-lib#9497 Migrate pubid plugin to vue3 --- plugins/pubIds/urn/URNPubIdPlugin.php | 2 +- plugins/pubIds/urn/js/FieldPubIdUrn.js | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/plugins/pubIds/urn/URNPubIdPlugin.php b/plugins/pubIds/urn/URNPubIdPlugin.php index b667878cb65..a801daf260e 100755 --- a/plugins/pubIds/urn/URNPubIdPlugin.php +++ b/plugins/pubIds/urn/URNPubIdPlugin.php @@ -470,7 +470,7 @@ public function loadUrnFieldComponent(string $hookName, array $args): void $templateMgr = $args[0]; $template = $args[1]; - if ($template !== 'workflow/workflow.tpl') { + if ($template !== 'dashboard/editors.tpl') { return; } diff --git a/plugins/pubIds/urn/js/FieldPubIdUrn.js b/plugins/pubIds/urn/js/FieldPubIdUrn.js index 2bb0a45b38c..cd4a989f5a2 100644 --- a/plugins/pubIds/urn/js/FieldPubIdUrn.js +++ b/plugins/pubIds/urn/js/FieldPubIdUrn.js @@ -11,9 +11,10 @@ * @brief A Vue.js component for URN field, that is used for pattern suffixes and that considers check number. */ -pkp.Vue.component('field-pub-id-urn', { +console.log('pubid test', pkp.registry.getComponent('field-pub-id')); +pkp.registry.registerComponent('FieldPubIdUrn', { name: 'FieldPubIdUrn', - extends: pkp.Vue.component('field-pub-id'), + extends: pkp.registry.getComponent('PkpFieldPubId'), props: { applyCheckNumber: { type: Boolean, @@ -22,10 +23,10 @@ pkp.Vue.component('field-pub-id-urn', { }, methods: { generateId() { - var id = pkp.Vue.component('field-pub-id').options.methods['generateId'].apply(this); + var id = pkp.Vue.component('field-pub-id').methods['generateId'].apply(this); return this.applyCheckNumber ? id + $.pkp.plugins.generic.urn.getCheckNumber(id, this.prefix) : id; } }, -}); \ No newline at end of file +}) From 88766e6ef900fba25a99fe3a40624ca69ee50f24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jarda=20Kot=C4=9B=C5=A1ovec?= Date: Tue, 14 Jan 2025 12:42:04 +0100 Subject: [PATCH 2/5] pkp/pkp-lib#9497 Clean up --- plugins/pubIds/urn/js/FieldPubIdUrn.js | 1 - 1 file changed, 1 deletion(-) diff --git a/plugins/pubIds/urn/js/FieldPubIdUrn.js b/plugins/pubIds/urn/js/FieldPubIdUrn.js index cd4a989f5a2..e9998897ee4 100644 --- a/plugins/pubIds/urn/js/FieldPubIdUrn.js +++ b/plugins/pubIds/urn/js/FieldPubIdUrn.js @@ -11,7 +11,6 @@ * @brief A Vue.js component for URN field, that is used for pattern suffixes and that considers check number. */ -console.log('pubid test', pkp.registry.getComponent('field-pub-id')); pkp.registry.registerComponent('FieldPubIdUrn', { name: 'FieldPubIdUrn', extends: pkp.registry.getComponent('PkpFieldPubId'), From 0c7f34a91b3e355d8b30166c8220164bc903c48d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jarda=20Kot=C4=9B=C5=A1ovec?= Date: Tue, 14 Jan 2025 12:43:24 +0100 Subject: [PATCH 3/5] pkp/pkp-lib#9497 Clean up --- plugins/pubIds/urn/js/FieldPubIdUrn.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/pubIds/urn/js/FieldPubIdUrn.js b/plugins/pubIds/urn/js/FieldPubIdUrn.js index e9998897ee4..f86e5cff517 100644 --- a/plugins/pubIds/urn/js/FieldPubIdUrn.js +++ b/plugins/pubIds/urn/js/FieldPubIdUrn.js @@ -22,7 +22,7 @@ pkp.registry.registerComponent('FieldPubIdUrn', { }, methods: { generateId() { - var id = pkp.Vue.component('field-pub-id').methods['generateId'].apply(this); + var id = pkp.registry.getComponent('PkpFieldPubId').methods['generateId'].apply(this); return this.applyCheckNumber ? id + $.pkp.plugins.generic.urn.getCheckNumber(id, this.prefix) : id; From 74e610056335e09359f1b60ba136ed479b14f22d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jarda=20Kot=C4=9B=C5=A1ovec?= Date: Tue, 14 Jan 2025 14:29:02 +0100 Subject: [PATCH 4/5] pkp/pkp-lib#9497 Since forms are retrieved from individual endpoints, addJavascript needs to be called when loading editors.tpl --- plugins/pubIds/urn/URNPubIdPlugin.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/plugins/pubIds/urn/URNPubIdPlugin.php b/plugins/pubIds/urn/URNPubIdPlugin.php index a801daf260e..3080fef68b1 100755 --- a/plugins/pubIds/urn/URNPubIdPlugin.php +++ b/plugins/pubIds/urn/URNPubIdPlugin.php @@ -345,10 +345,6 @@ public function addPublicationFormFields(string $hookName, FormComponent $form): $appyCheckNumber = $this->getSetting($form->submissionContext->getId(), 'urnCheckNo'); - if ($appyCheckNumber) { - // Load the checkNumber.js file that is required for URN fields - $this->addJavaScript(Application::get()->getRequest(), TemplateManager::getManager(Application::get()->getRequest())); - } // If a pattern exists, use a DOI-like field to generate the URN if ($pattern) { $fieldData = [ @@ -476,6 +472,14 @@ public function loadUrnFieldComponent(string $hookName, array $args): void $context = Application::get()->getRequest()->getContext(); $suffixType = $this->getSetting($context->getId(), 'urnSuffix'); + + $appyCheckNumber = $this->getSetting($context->getId(), 'urnCheckNo'); + + if ($appyCheckNumber) { + // Load the checkNumber.js file that is required for URN fields + $this->addJavaScript(Application::get()->getRequest(), TemplateManager::getManager(Application::get()->getRequest())); + } + if ($suffixType === 'default' || $suffixType === 'pattern') { $templateMgr->addJavaScript( 'field-pub-id-urn-component', From 9b443843d6b5faf9a8c823c5cc5b3270e311e5a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jarda=20Kot=C4=9B=C5=A1ovec?= Date: Wed, 15 Jan 2025 15:34:20 +0100 Subject: [PATCH 5/5] pkp/pkp-lib#9497 Migrate FieldTextUrn to vue3 --- plugins/pubIds/urn/js/FieldTextUrn.js | 111 +++++++++++++------------- 1 file changed, 56 insertions(+), 55 deletions(-) diff --git a/plugins/pubIds/urn/js/FieldTextUrn.js b/plugins/pubIds/urn/js/FieldTextUrn.js index f7625f4cfdb..dd45e673261 100644 --- a/plugins/pubIds/urn/js/FieldTextUrn.js +++ b/plugins/pubIds/urn/js/FieldTextUrn.js @@ -10,76 +10,77 @@ * * @brief A Vue.js component for URN text form field, that is used for custom suffixes, and that considers adding a check number. */ -var template = pkp.Vue.compile('
' + -' ' + -' ' + -'
' + -' ' + -' ' + -' {{ addCheckNumberLabel }}' + -' ' + -' ' + -'
' + -'
' + -' '); -pkp.Vue.component('field-text-urn', { +pkp.registry.registerComponent('FieldTextUrn', { name: 'FieldTextUrn', - extends: pkp.Vue.component('field-text'), + extends: pkp.registry.getComponent('PkpFieldText'), + template: + '
' + + ' ' + + ' ' + + '
' + + ' ' + + ' ' + + ' {{ addCheckNumberLabel }}' + + ' ' + + ' ' + + '
' + + '
' + + ' ', props: { addCheckNumberLabel: { type: String, - required: true + required: true, }, urnPrefix: { type: String, - required: true + required: true, }, applyCheckNumber: { type: Boolean, - required: true - } + required: true, + }, }, methods: { /** * Add a check number to the end of the URN */ addCheckNumber() { - this.currentValue += $.pkp.plugins.generic.urn.getCheckNumber(this.currentValue, this.urnPrefix); - } + this.currentValue += $.pkp.plugins.generic.urn.getCheckNumber( + this.currentValue || '', + this.urnPrefix, + ); + }, }, - render: function(h) { - return template.render.call(this, h); - } -}); \ No newline at end of file +});