1313 * @brief Thoth config for publish form
1414 */
1515
16+ use ThothApi \GraphQL \Models \Work as ThothWork ;
17+
1618import ('plugins.generic.thoth.classes.facades.ThothService ' );
1719import ('plugins.generic.thoth.classes.facades.ThothRepo ' );
1820
@@ -48,12 +50,12 @@ public function addConfig($hookName, $form)
4850 return false ;
4951 }
5052
51- $ this ->addFields ($ form , $ imprints );
53+ $ this ->addFields ($ form , $ imprints, $ submission -> getData ( ' workType ' ) );
5254
5355 return false ;
5456 }
5557
56- private function addFields ($ form , $ imprints )
58+ private function addFields ($ form , $ imprints, $ workType )
5759 {
5860 $ imprintOptions = [];
5961 foreach ($ imprints as $ imprint ) {
@@ -71,14 +73,38 @@ private function addFields($form, $imprints)
7173 'value ' => false ,
7274 'groupId ' => 'default ' ,
7375 ]))
74- ->addField (new \PKP \components \forms \FieldSelect ('imprint ' , [
76+ ->addField (new \PKP \components \forms \FieldSelect ('thothImprintId ' , [
7577 'label ' => __ ('plugins.generic.thoth.imprint ' ),
7678 'options ' => $ imprintOptions ,
7779 'required ' => true ,
7880 'showWhen ' => 'registerConfirmation ' ,
7981 'groupId ' => 'default ' ,
8082 'value ' => $ imprintOptions [0 ]['value ' ] ?? null
8183 ]));
84+
85+ if ($ workType !== WORK_TYPE_AUTHORED_WORK ) {
86+ return ;
87+ }
88+
89+ $ workTypeOptions = [
90+ [
91+ 'value ' => ThothWork::WORK_TYPE_MONOGRAPH ,
92+ 'label ' => __ ('plugins.generic.thoth.workType.monograph ' )
93+ ],
94+ [
95+ 'value ' => ThothWork::WORK_TYPE_TEXTBOOK ,
96+ 'label ' => __ ('plugins.generic.thoth.workType.textbook ' )
97+ ],
98+ ];
99+
100+ $ form ->addField (new \PKP \components \forms \FieldSelect ('thothWorkType ' , [
101+ 'label ' => __ ('plugins.generic.thoth.workType ' ),
102+ 'options ' => $ workTypeOptions ,
103+ 'required ' => true ,
104+ 'showWhen ' => 'registerConfirmation ' ,
105+ 'groupId ' => 'default ' ,
106+ 'value ' => $ workTypeOptions [0 ]['value ' ] ?? null
107+ ]));
82108 }
83109
84110 private function showErrors ($ form , $ errors )
0 commit comments