Skip to content

Commit 7dc027f

Browse files
committed
refactor: extract service classes and expand test coverage
- Extract BaseManagement, EditorAssignmentService, IssueRepository, and SubmissionFormHandler classes - Refactor IssueManagement and SubmissionManagement to use extracted services - Expand Cypress test coverage with TypeScript support - Update GitHub Actions workflow configuration - Add Prettier and jsconfig configuration - Remove obsolete test screenshots - Bump version to 1.6.0.4 with lazy-load enabled
1 parent 05067c8 commit 7dc027f

24 files changed

+1808
-552
lines changed

.github/actions/tests.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22

33
set -e
44

5-
npx cypress run --headless --browser chrome --config '{"specPattern":["plugins/generic/pluginTemplate/cypress/tests/functional/*.cy.js"]}'
5+
npx cypress run --headless --browser chrome --config '{"specPattern":["plugins/generic/issuePreselection/cypress/tests/functional/*.cy.js"]}'
66

77

.github/workflows/main.yml

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,41 @@
1-
on: [push]
2-
name: pluginTemplate
1+
on: [push, pull_request]
2+
name: issuePreselection
33
jobs:
4-
pluginTemplate:
4+
issuePreselection:
55
runs-on: ubuntu-latest
66
strategy:
77
fail-fast: false
88
matrix:
99
include:
10-
- application: ojs
11-
php-version: 8.3
12-
database: mysql
1310
- application: ojs
1411
php-version: 8.2
1512
database: mysql
16-
- application: ojs
17-
php-version: 8.3
18-
database: pgsql
13+
ojs-version: stable-3_5_0
1914
- application: ojs
2015
php-version: 8.2
2116
database: pgsql
17+
ojs-version: stable-3_5_0
2218

23-
name: pluginTemplate
19+
name: ${{ matrix.application }} - PHP ${{ matrix.php-version }} - ${{ matrix.database }}
2420
steps:
25-
- uses: pkp/pkp-github-actions@v1
21+
- name: Checkout plugin
22+
uses: actions/checkout@v4
23+
with:
24+
path: issuePreselection
25+
26+
- name: Run PKP plugin tests
27+
uses: pkp/pkp-github-actions@v1
2628
with:
2729
node_version: 20
28-
branch: main
30+
branch: ${{ matrix.ojs-version }}
2931
repository: pkp
30-
plugin: true
32+
plugin: issuePreselection
33+
34+
- name: Run Cypress tests
35+
if: matrix.php-version == '8.2' && matrix.database == 'mysql'
36+
working-directory: issuePreselection
37+
run: |
38+
npm install
39+
npx cypress run
40+
env:
41+
CYPRESS_BASE_URL: http://localhost

.prettierrc

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,39 @@
77
"trailingComma": "none",
88
"phpVersion": "8.2",
99
"braceStyle": "psr-2",
10-
"embeddedLanguageFormatting": "auto"
10+
"embeddedLanguageFormatting": "auto",
11+
"endOfLine": "lf",
12+
"useTabs": false,
13+
"arrowParens": "always",
14+
"bracketSpacing": true,
15+
"htmlWhitespaceSensitivity": "css",
16+
"overrides": [
17+
{
18+
"files": "*.vue",
19+
"options": {
20+
"parser": "vue"
21+
}
22+
},
23+
{
24+
"files": ["*.cy.js", "*.spec.js"],
25+
"options": {
26+
"printWidth": 100
27+
}
28+
},
29+
{
30+
"files": "*.tpl",
31+
"options": {
32+
"parser": "html",
33+
"htmlWhitespaceSensitivity": "ignore"
34+
}
35+
},
36+
{
37+
"files": ["*.md", "*.mdx"],
38+
"options": {
39+
"printWidth": 80,
40+
"proseWrap": "always",
41+
"tabWidth": 2
42+
}
43+
}
44+
]
1145
}

IssuePreselectionPlugin.php

Lines changed: 67 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,21 @@
1616
use APP\core\Application;
1717
use APP\plugins\generic\issuePreselection\classes\IssueManagement;
1818
use APP\plugins\generic\issuePreselection\classes\SubmissionManagement;
19+
use Exception;
1920
use PKP\plugins\GenericPlugin;
2021
use PKP\plugins\Hook;
2122

2223
class IssuePreselectionPlugin extends GenericPlugin
2324
{
2425
/**
2526
* @copydoc GenericPlugin::register()
27+
*
28+
* @param string $category The category of the plugin
29+
* @param string $path The path to the plugin
30+
* @param int|null $mainContextId The main context ID
31+
*
32+
* @return bool True if registration was successful
33+
* @throws Exception
2634
*/
2735
public function register($category, $path, $mainContextId = null): bool
2836
{
@@ -40,37 +48,55 @@ public function register($category, $path, $mainContextId = null): bool
4048
}
4149

4250
/**
43-
* @copydoc Plugin::getDisplayName()
44-
* @noinspection PhpUnused
51+
* Register hooks used in normal plugin setup and in CLI tools
52+
*
53+
* Initializes the management classes and registers all necessary hooks
54+
* for both issue and submission functionality.
55+
*
56+
* @return void
57+
* @throws Exception
4558
*/
46-
public function getDisplayName(): object|array|string|null
59+
private function _init(): void
4760
{
48-
return __("plugins.generic.issuePreselection.displayName");
49-
}
61+
$issueManagement = new IssueManagement($this);
62+
$submissionManagement = new SubmissionManagement($this);
5063

51-
/**
52-
* @copydoc Plugin::getDescription()
53-
* @noinspection PhpUnused
54-
*/
55-
public function getDescription(): object|array|string|null
56-
{
57-
return __("plugins.generic.issuePreselection.description");
64+
$this->registerIssueHooks($issueManagement);
65+
$this->registerSubmissionHooks($submissionManagement);
5866
}
5967

6068
/**
61-
* Rgister hooks used in normal plugin setup and in CLI tools.
69+
* Register hooks for issue management functionality
70+
*
71+
* Registers all hooks related to issue schema, forms, and data handling.
72+
*
73+
* @param IssueManagement $issueManagement The issue management instance
74+
*
75+
* @return void
76+
* @throws Exception
6277
*/
63-
private function _init() : void
78+
private function registerIssueHooks(IssueManagement $issueManagement): void
6479
{
65-
$issueManagement = new IssueManagement($this);
66-
$submissionManagement = new SubmissionManagement($this);
67-
6880
Hook::add("Schema::get::issue", [$issueManagement, "addToIssueSchema"]);
6981
Hook::add("Templates::Editor::Issues::IssueData::AdditionalMetadata", [$issueManagement, "addIssueFormFields"]);
7082
Hook::add("issueform::readuservars", [$issueManagement, "readIssueFormData"]);
7183
Hook::add("issueform::execute", [$issueManagement, "saveIssueFormData"]);
7284
Hook::add("Issue::edit", [$issueManagement, "beforeIssueEdit"]);
85+
}
7386

87+
/**
88+
* Register hooks for submission management functionality
89+
*
90+
* Registers all hooks related to submission schema, forms, validation,
91+
* and editor assignment.
92+
*
93+
* @param SubmissionManagement $submissionManagement The submission management instance
94+
*
95+
* @return void
96+
* @throws Exception
97+
*/
98+
private function registerSubmissionHooks(SubmissionManagement $submissionManagement): void
99+
{
74100
Hook::add("Schema::get::submission", [$submissionManagement, "addToSubmissionSchema"]);
75101
Hook::add("Form::config::after", [$submissionManagement, "addToSubmissionForm"]);
76102
Hook::add("Submission::getSubmissionsListProps", [$submissionManagement, "addSubmissionListProps"]);
@@ -80,6 +106,30 @@ private function _init() : void
80106
]);
81107
Hook::add("Submission::validateSubmit", [$submissionManagement, "handleSubmissionValidate"]);
82108
}
109+
110+
/**
111+
* Get the display name of this plugin
112+
*
113+
* @copydoc Plugin::getDisplayName()
114+
*
115+
* @return object|array|string|null Localized plugin display name
116+
*/
117+
public function getDisplayName(): object|array|string|null
118+
{
119+
return __("plugins.generic.issuePreselection.displayName");
120+
}
121+
122+
/**
123+
* Get the description of this plugin
124+
*
125+
* @copydoc Plugin::getDescription()
126+
*
127+
* @return object|array|string|null Localized plugin description
128+
*/
129+
public function getDescription(): object|array|string|null
130+
{
131+
return __("plugins.generic.issuePreselection.description");
132+
}
83133
}
84134

85135
// For backwards compatibility -- expect this to be removed approx. OJS/OMP/OPS 3.6

README.md

Lines changed: 33 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,28 @@
2121

2222
## Overview
2323

24-
The Issue Preselection Plugin allows authors to select which journal issue their submission should be assigned to during the submission process. Editors can configure which issues are open for submissions and pre-assign guest editors who will automatically be assigned to incoming submissions.
24+
The Issue Preselection Plugin allows authors to select which journal issue their
25+
submission should be assigned to during the submission process. Editors can
26+
configure which issues are open for submissions and pre-assign guest editors who
27+
will automatically be assigned to incoming submissions.
2528

2629
## Features
2730

2831
### For Authors
2932

30-
- **Issue Selection During Submission** - Select from available future issues when submitting
31-
- **Direct Response to Calls for Papers** - Submit directly to specific themed issues
33+
- **Issue Selection During Submission** - Select from available future issues
34+
when submitting
35+
- **Direct Response to Calls for Papers** - Submit directly to specific themed
36+
issues
3237
- **Filtered Issue List** - Only see issues that editors have marked as open
3338

3439
### For Editors
3540

3641
- **Issue Configuration** - Mark issues as open/closed for author selection
37-
- **Editor Pre-assignment** - Assign guest editors to issues for automatic workflow assignment
38-
- **Automatic Workflow** - Submissions automatically assigned to configured editors with notifications
42+
- **Editor Pre-assignment** - Assign guest editors to issues for automatic
43+
workflow assignment
44+
- **Automatic Workflow** - Submissions automatically assigned to configured
45+
editors with notifications
3946

4047
## Requirements
4148

@@ -47,9 +54,11 @@ The Issue Preselection Plugin allows authors to select which journal issue their
4754

4855
### Method 1: Manual Installation
4956

50-
1. Download the latest release from the [releases page](https://github.com/abenteuerzeit/ojs-issue-preselection/releases)
57+
1. Download the latest release from the
58+
[releases page](https://github.com/abenteuerzeit/ojs-issue-preselection/releases)
5159
2. Extract the archive
52-
3. Copy the `issuePreselection` folder to `plugins/generic/` in your OJS installation
60+
3. Copy the `issuePreselection` folder to `plugins/generic/` in your OJS
61+
installation
5362
4. Log in to OJS as Administrator
5463
5. Navigate to **Settings > Website > Plugins**
5564
6. Find "Issue Preselection Plugin" under Generic Plugins
@@ -80,7 +89,8 @@ Click **Create** or **Edit** on an issue you want to configure
8089

8190
<img width="800" alt="Create or Edit Issue" src="https://github.com/user-attachments/assets/87174d46-2cea-44f8-a2a1-17da128cb721" />
8291

83-
**Edit** is shown after expanding the view by clicking on the triangular bullet to the left of the issue. You can also click on the name directly.
92+
**Edit** is shown after expanding the view by clicking on the triangular bullet
93+
to the left of the issue. You can also click on the name directly.
8494

8595
<img width="800" alt="Issue Options" src="https://github.com/user-attachments/assets/a5bb768d-a66b-4de7-861f-681eea1ec99f" />
8696

@@ -90,8 +100,13 @@ You'll see two new fields under **Issue Data**
90100

91101
<img width="800" alt="Issue Data Fields" src="https://github.com/user-attachments/assets/cfa5bb5e-c359-44a3-bddd-73e04fbc0d60" />
92102

93-
- **Enable for Submission**: Check to make this issue available for author selection
94-
- **Assigned Editors (Optional)**: Select one or more editors to automatically assign to submissions
103+
- **Enable for Submission**: Check to make this issue available for author
104+
selection
105+
- **Assigned Editors (Optional)**: Select one or more editors to automatically
106+
assign to submissions
107+
108+
> Updates to editor assignments under the issue data tab apply to all active
109+
> submissions assigned to an issue and not scheduled for publication.
95110
96111
**Step 4: Save Changes**
97112

@@ -158,7 +173,8 @@ The plugin uses OJS's hook system exclusively for integration:
158173
- **Schema Hooks**: Extend issue and submission schemas with custom fields
159174
- **Form Hooks**: Add UI elements to issue and submission forms
160175
- **Template Hooks**: Display selected issue in review section
161-
- **Validation Hooks**: Process issue assignment and editor assignment on submission
176+
- **Validation Hooks**: Process issue assignment and editor assignment on
177+
submission
162178

163179
### Data Storage
164180

@@ -215,8 +231,10 @@ The plugin logs extensively with `[IssuePreselection]` prefix.
215231

216232
## Support
217233

218-
- **Issues**: [GitHub Issues](https://github.com/yourusername/ojs-issue-preselection/issues)
219-
- **Documentation**: [Wiki](https://github.com/yourusername/ojs-issue-preselection/wiki)
234+
- **Issues**:
235+
[GitHub Issues](https://github.com/abenteuerzeit/ojs-issue-preselection/issues)
236+
- **Documentation**:
237+
[Wiki](https://github.com/abenteuerzeit/ojs-issue-preselection/wiki)
220238
- **OJS Forum**: [PKP Community Forum](https://forum.pkp.sfu.ca/)
221239

222240
## Contributing
@@ -230,4 +248,5 @@ Contributions are welcome! Please:
230248

231249
## License
232250

233-
This plugin is licensed under the GNU General Public License v3.0. See [LICENSE](LICENSE) for details.
251+
This plugin is licensed under the GNU General Public License v3.0. See
252+
[LICENSE](LICENSE) for details.

0 commit comments

Comments
 (0)