Skip to content

Commit

Permalink
pkp/pkp-lib#8940 consider urnCheckNo setting, fix publish preview, re…
Browse files Browse the repository at this point in the history
…move OJS code
  • Loading branch information
bozana committed Apr 27, 2023
1 parent f1f2878 commit 52b987d
Show file tree
Hide file tree
Showing 10 changed files with 246 additions and 139 deletions.
2 changes: 1 addition & 1 deletion classes/plugins/PubIdPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,6 @@ public function checkDuplicate($pubId, $pubObjectType, $excludeId, $contextId)
}
}

return true;
return parent::checkDuplicate($pubId, $pubObjectType, $excludeId, $contextId);
}
}
2 changes: 2 additions & 0 deletions js/load.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import CatalogListPanel from '@/components/ListPanel/submissions/CatalogListPane

// Required by the URN plugin
import FieldText from '@/components/Form/fields/FieldText.vue';
import FieldPubId from '@/components/Form/fields/FieldPubId.vue';

// Expose Vue, the registry and controllers in a global var
window.pkp = Object.assign(PkpLoad, {
Expand Down Expand Up @@ -65,4 +66,5 @@ window.pkp = Object.assign(PkpLoad, {

// Required by the URN plugin
window.pkp.Vue.component('field-text', FieldText);
window.pkp.Vue.component('field-pub-id', FieldPubId);
window.pkp.Vue.component('catalog-list-panel', CatalogListPanel);
200 changes: 112 additions & 88 deletions plugins/pubIds/urn/URNPubIdPlugin.php

Large diffs are not rendered by default.

35 changes: 35 additions & 0 deletions plugins/pubIds/urn/classes/form/FieldPubIdUrn.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

/**
* @file plugins/pubIds/urn/classes/form/FieldPubIdUrn.php
*
* Copyright (c) 2014-2022 Simon Fraser University
* Copyright (c) 2000-2022 John Willinsky
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
*
* @class FieldPubIdUrn
*
* @brief URN field, that is used for pattern suffixes and that considers check number.
*/

namespace APP\plugins\pubIds\urn\classes\form;

use PKP\components\forms\FieldPubId;

class FieldPubIdUrn extends FieldPubId
{
/** @copydoc Field::$component */
public $component = 'field-pub-id-urn';

public bool $applyCheckNumber = false;

/**
* @copydoc Field::getConfig()
*/
public function getConfig()
{
$config = parent::getConfig();
$config['applyCheckNumber'] = $this->applyCheckNumber;
return $config;
}
}
39 changes: 39 additions & 0 deletions plugins/pubIds/urn/classes/form/FieldTextUrn.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

/**
* @file plugins/pubIds/urn/classes/form/FieldTextUrn.php
*
* Copyright (c) 2014-2022 Simon Fraser University
* Copyright (c) 2000-2022 John Willinsky
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
*
* @class FieldTextUrn
*
* @brief A field for entering a custom URN that also considers adding a check number.
*/

namespace APP\plugins\pubIds\urn\classes\form;

use PKP\components\forms\FieldText;

class FieldTextUrn extends FieldText
{
/** @copydoc Field::$component */
public $component = 'field-text-urn';

public string $urnPrefix = '';

public bool $applyCheckNumber = false;

/**
* @copydoc Field::getConfig()
*/
public function getConfig()
{
$config = parent::getConfig();
$config['urnPrefix'] = $this->urnPrefix;
$config['applyCheckNumber'] = $this->applyCheckNumber;
$config['addCheckNumberLabel'] = __('plugins.pubIds.urn.editor.addCheckNo');
return $config;
}
}
38 changes: 0 additions & 38 deletions plugins/pubIds/urn/classes/form/FieldUrn.php

This file was deleted.

31 changes: 31 additions & 0 deletions plugins/pubIds/urn/js/FieldPubIdUrn.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/**
* @defgroup plugins_pubIds_urn_js
*/
/**
* @file plugins/pubIds/urn/js/FieldPubIdUrn.js
*
* Copyright (c) 2014-2021 Simon Fraser University
* Copyright (c) 2003-2021 John Willinsky
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
*
* @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', {
name: 'FieldPubIdUrn',
extends: pkp.Vue.component('field-pub-id'),
props: {
applyCheckNumber: {
type: Boolean,
required: true
}
},
methods: {
generateId() {
var id = pkp.Vue.component('field-pub-id').options.methods['generateId'].apply(this);
return this.applyCheckNumber
? id + $.pkp.plugins.generic.urn.getCheckNumber(id, this.prefix)
: id;
}
},
});
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
* @defgroup plugins_pubIds_urn_js
*/
/**
* @file plugins/pubIds/urn/js/FieldUrn.js
* @file plugins/pubIds/urn/js/FieldTextUrn.js
*
* Copyright (c) 2014-2021 Simon Fraser University
* Copyright (c) 2003-2021 John Willinsky
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
*
* @brief A Vue.js component for a URN form field that adds a check number.
* @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('<div class="pkpFormField pkpFormField--text pkpFormField--urn" :class="classes">' +
' <form-field-label' +
Expand Down Expand Up @@ -39,6 +39,7 @@ var template = pkp.Vue.compile('<div class="pkpFormField pkpFormField--text pkpF
' :style="inputStyles"' +
' />' +
' <button' +
' v-if="applyCheckNumber"' +
' class="pkpButton pkpFormField--urn__button"' +
' @click.prevent="addCheckNumber"' +
' >' +
Expand All @@ -53,13 +54,21 @@ var template = pkp.Vue.compile('<div class="pkpFormField pkpFormField--text pkpF
' </div>' +
' </div>');

pkp.Vue.component('field-urn', {
name: 'FieldUrn',
pkp.Vue.component('field-text-urn', {
name: 'FieldTextUrn',
extends: pkp.Vue.component('field-text'),
props: {
addCheckNumberLabel: {
type: String,
required: true
},
urnPrefix: {
type: String,
required: true
},
applyCheckNumber: {
type: Boolean,
required: true
}
},
methods: {
Expand Down
11 changes: 5 additions & 6 deletions plugins/pubIds/urn/js/checkNumber.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,10 @@
};

// Apply the check number when the button is clicked
$('#checkNo').click(function() {
var urnPrefix = $('[id^="urnPrefix"]').val(),
urnSuffix = $('[id^="urnSuffix"]').val();
urn = urnPrefix + urnSuffix;
$('[id^="urnSuffix"]').val(urnSuffix + $.pkp.plugins.generic.urn.getCheckNumber(urn, urnPrefix));
});
$('#checkNo').on('click', () => {
var urnPrefix = $('[id^="urnPrefix"]').val(), urnSuffix = $('[id^="urnSuffix"]').val();
urn = urnPrefix + urnSuffix;
$('[id^="urnSuffix"]').val(urnSuffix + $.pkp.plugins.generic.urn.getCheckNumber(urn, urnPrefix));
});

}(jQuery));
10 changes: 8 additions & 2 deletions plugins/pubIds/urn/locale/en/locale.po
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,14 @@ msgstr "The URN for this publication will be {$urn}."
msgid "plugins.pubIds.urn.editor.preview.publication.none"
msgstr "A URN has not been assigned to this publication."

msgid "plugins.pubIds.urn.editor.preview.galleys"
msgstr "Galley: {$galleyLabel}"
msgid "plugins.pubIds.urn.editor.preview.chapters"
msgstr "Chapter: {$chapterLabel}"

msgid "plugins.pubIds.urn.editor.preview.publicationFormats"
msgstr "Publication Format: {$publicationFormatLabel}"

msgid "plugins.pubIds.urn.editor.preview.submissionFiles"
msgstr "Files: {$submissionFileLabel}"

msgid "plugins.pubIds.urn.editor.preview.objects"
msgstr "Item"

0 comments on commit 52b987d

Please sign in to comment.