diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..36176dd Binary files /dev/null and b/.DS_Store differ diff --git a/modules/.DS_Store b/modules/.DS_Store new file mode 100644 index 0000000..4981976 Binary files /dev/null and b/modules/.DS_Store differ 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