1515 */
1616
1717use APP \facades \Repo ;
18+ use APP \submission \Submission ;
19+ use ThothApi \GraphQL \Models \Work as ThothWork ;
1820
1921import ('plugins.generic.thoth.classes.facades.ThothService ' );
2022import ('plugins.generic.thoth.classes.facades.ThothRepository ' );
@@ -51,12 +53,12 @@ public function addConfig($hookName, $form)
5153 return false ;
5254 }
5355
54- $ this ->addFields ($ form , $ imprints );
56+ $ this ->addFields ($ form , $ imprints, $ submission -> getData ( ' workType ' ) );
5557
5658 return false ;
5759 }
5860
59- private function addFields ($ form , $ imprints )
61+ private function addFields ($ form , $ imprints, $ workType )
6062 {
6163 $ imprintOptions = [];
6264 foreach ($ imprints as $ imprint ) {
@@ -74,14 +76,38 @@ private function addFields($form, $imprints)
7476 'value ' => false ,
7577 'groupId ' => 'default ' ,
7678 ]))
77- ->addField (new \PKP \components \forms \FieldSelect ('imprint ' , [
79+ ->addField (new \PKP \components \forms \FieldSelect ('thothImprintId ' , [
7880 'label ' => __ ('plugins.generic.thoth.imprint ' ),
7981 'options ' => $ imprintOptions ,
8082 'required ' => true ,
8183 'showWhen ' => 'registerConfirmation ' ,
8284 'groupId ' => 'default ' ,
8385 'value ' => $ imprintOptions [0 ]['value ' ] ?? null
8486 ]));
87+
88+ if ($ workType !== Submission::WORK_TYPE_AUTHORED_WORK ) {
89+ return ;
90+ }
91+
92+ $ workTypeOptions = [
93+ [
94+ 'value ' => ThothWork::WORK_TYPE_MONOGRAPH ,
95+ 'label ' => __ ('plugins.generic.thoth.workType.monograph ' )
96+ ],
97+ [
98+ 'value ' => ThothWork::WORK_TYPE_TEXTBOOK ,
99+ 'label ' => __ ('plugins.generic.thoth.workType.textbook ' )
100+ ],
101+ ];
102+
103+ $ form ->addField (new \PKP \components \forms \FieldSelect ('thothWorkType ' , [
104+ 'label ' => __ ('plugins.generic.thoth.workType ' ),
105+ 'options ' => $ workTypeOptions ,
106+ 'required ' => true ,
107+ 'showWhen ' => 'registerConfirmation ' ,
108+ 'groupId ' => 'default ' ,
109+ 'value ' => $ workTypeOptions [0 ]['value ' ] ?? null
110+ ]));
85111 }
86112
87113 private function showErrors ($ form , $ errors )
0 commit comments