From 74b241a06137d1b3ae94cbf8626dcd3c683889a4 Mon Sep 17 00:00:00 2001 From: = <=> Date: Thu, 31 Aug 2017 16:44:40 -0400 Subject: [PATCH] initial commit for settings file --- .DS_Store | Bin 0 -> 8196 bytes modules/.DS_Store | Bin 0 -> 6148 bytes .../commerce_pos_admin.info.yml | 7 + .../commerce_pos_admin.module | 124 ++++++++++++++++++ .../commerce_pos_admin.routing.yml | 7 + 5 files changed, 138 insertions(+) create mode 100644 .DS_Store create mode 100644 modules/.DS_Store create mode 100644 modules/commerce_pos_admin/commerce_pos_admin.info.yml create mode 100644 modules/commerce_pos_admin/commerce_pos_admin.module create mode 100644 modules/commerce_pos_admin/commerce_pos_admin.routing.yml diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..36176dd6195ba66ba13219222ab3eb9a83d72f64 GIT binary patch literal 8196 zcmeHML2lDP6#dhtjiZ7nYDK&B28l&gH7cU25K;*3q6;KM5G(+-c4HbB$F|~x03j$F z?of`vO}GIE;Q;Xd%+$3fG|Pg-Of>T+6$_}FB*pH^rcEBoN6|f3e1*`&Afqy{(JhQntmpu2?QQKMttOEa~ z0(^gPQQ0=MohU1B9cW|<09(PZEa)Q-kUp-q4Q(gNN>^~I>_KQ(p;HW@+;QAxIBY}P ziL%O_gmNdLXBIj`5ps6;xe`vIp{#AK0#<=(1vq!F(lJHkA$u?6?}?8id@J z^oUl0PN<7dKt1#WI;0dM8Et|ir4Tly4yEcnK+f~c;JG=2C#0C(P*P?PYX-xtl`um_ zeXJ;=$l&>6@T|;ONf&3rtN)%W^? ztm*Y$%5Pyi@OA%Ll0^cD6R$yW981W5-#$U4L+J)cx>r^lAM03>u*b{otY->U-XP zMbFUWU8@&INqoX?sMl~kd5FSW9W@zcXc(9G2S>W3U5%d7K0Ty8dJMY>-P?u-;$8Bn zVAsj}fPq7tOSlDGS=bF|%{|J|eqV?-BRjz2Zc*lxk-k9M=YPH-Y{x2aB?`=|S=KrK z-@p9*|COx8PGS|X3j7@fL}jnF*TmfCKT*tOaIWp59-(q!+(cRFf<~s}ureKo&Hpe& a-vyL?8rn{j#R!Uh5g=u-jaA@E75EJ)-bG6Q literal 0 HcmV?d00001 diff --git a/modules/.DS_Store b/modules/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..4981976e6e0d64481a02acc83ca18681cb811b79 GIT binary patch literal 6148 zcmeHKJx{|x47E##B9;mv#CRhsGs~$e12aDWNYVi*^s1yC*s}0r_?7T{wyHJ(#DoyF zE8lY*`##=P@f{KIY*SqkO^Ij%6&xL-`9$Qs=s-s183Q@@v7m-ZTF^bM2GQ>Liwwx# zonp@tJ>$2#e~DV`<0Dn@Khg5GPGwQ20`c-^xrSc8XMy#@KB~5?iBM&VU>lk3hQfJt^dE9Kaa8oy8E^*n8936%snq|QukZi+N&e&vI0OHR z0Upoq<})nGYU^NeQfmYB0V*PKo#HkHMlQvOl~Q~G%>sWA0~ifEMR*{75Xdxm;|%;N F10Q;LPEP;; literal 0 HcmV?d00001 diff --git a/modules/commerce_pos_admin/commerce_pos_admin.info.yml b/modules/commerce_pos_admin/commerce_pos_admin.info.yml new file mode 100644 index 0000000..1679ddd --- /dev/null +++ b/modules/commerce_pos_admin/commerce_pos_admin.info.yml @@ -0,0 +1,7 @@ +name: Commerce POS Admin +type: module +description: Provides Admin Functionality for Commerce POS +core: 8.x +package: Commerce +dependencies: + - commerce_pos diff --git a/modules/commerce_pos_admin/commerce_pos_admin.module b/modules/commerce_pos_admin/commerce_pos_admin.module new file mode 100644 index 0000000..536de5c --- /dev/null +++ b/modules/commerce_pos_admin/commerce_pos_admin.module @@ -0,0 +1,124 @@ +config('example.settings'); + + $form['product_settings']['commerce_pos_available_products'] = array( + '#type' => 'textfield', + '#title' => $this->t('Available Products'), + + // might be a newer way to do this + '#options' => $product_options, + '#default_value' => $config->get('commerce_pos_available_products'), + ); + + + // In the D7 module some light meta programmming was being utlized to generate a form for field options for each product type. Need to investigate the best way to do this in D8 + + //possibly loading all the entity modules before hand and looping and doing generation a bit cleaner could be better. + $form['product_settings']['product_types'] = array( + '#type' => 'textfield', + '#title' => $this->t('Other things'), + '#default_value' => $config->get('other_things'), + ); + + + $form['product_settings']['product_search'] = array( + '#type' => 'textfield', + '#title' => $this->t('Search'), + '#default_value' => $config->get('product_search'), + ); + + // need to investigate more seach api details in d8 to realize the best way to accomplish. + + // if works the same way then a series of search api fields are required. + + $form['product_settings']['product_payments'] = array( + '#type' => 'textfield', + '#title' => $this->t('Product Payments'), + '#default_value' => $config->get('product_payments_default_payment_method'), + ); + + return parent::buildForm($form, $form_state); + } + + /** + * {@inheritdoc} + */ + public function submitForm(array &$form, FormStateInterface $form_state) { + + \Drupal::configFactory()->getEditable('commerce_pos_admin.settings') + // Set the submitted configuration setting + ->set('things', $form_state->getValue('example_thing')) + + /* Need to verify if form values and settings are correct and reflect the nature of how settings will be handled before any save functionality is done. */ + + + ->set('other_things', $form_state->getValue('other_things')) + ->save(); + + //validation of course needed as well + parent::submitForm($form, $form_state); + } +} \ No newline at end of file diff --git a/modules/commerce_pos_admin/commerce_pos_admin.routing.yml b/modules/commerce_pos_admin/commerce_pos_admin.routing.yml new file mode 100644 index 0000000..8fe119d --- /dev/null +++ b/modules/commerce_pos_admin/commerce_pos_admin.routing.yml @@ -0,0 +1,7 @@ +commerce_pos.settings: + path: '/admin/structure/commerce_pos/settings' + defaults: + _form: '\Drupal\example\Form\CommercePosSettingsForm' + _title: 'Commerce POS' + requirements: + _permission: 'administer Commerce Pos settings' \ No newline at end of file