public function create($values) { $page = \reasg\ui_views::createDefaultView(); $recordView = \reasg\ui_template::create("record.view"); $recordView->set("record_title", "New Employee Record"); $page->body->write($recordView); $ds = \reasg\ui_datasource::createDataset('student_record'); //Settings items individually $ds->items['std_sn'] = '812150001'; $ds->items['std_name'] = 'Joe Cuevas Garcia'; $ds->items['std_ssn'] = ['123', '45', '6789']; $ds->items['std_dob'] = '09/22/1998'; $ds->items['std_sex'] = 'm'; $ds->items['languages'] = ['sp', 'en']; //bind this ds to fields in a view with //the same name as this ds $ds->bindToView(); //reasg_dev_dump($recordView); }
public function edit($values) { $page = \reasg\ui_views::createDefaultView(); $ds = \reasg\ui_datasource::createDataset('employee'); //Settings items individually $ds->items['email'] = 'jose.cuevas'; $ds->items['emp_name'] = 'Jose'; $ds->items['emp_mname'] = 'L'; $ds->items['emp_lname'] = 'Cuevas Garcia'; $ds->items['emp_state'] = 'pr'; $ds->items['emp_city'] = 'mc'; $ds->items['field_enabled'] = '0'; $ds->items['start_date'] = '09/20/2015'; $ds->items['field_checkbox01'] = ['1', '2']; $ds->items['field_radio01'] = '2'; //populate a repeater table $ds->items['records2'] = [['id' => '001', 'school_name' => 'Vilmari Sanchez', 'town' => 'ri', 'date_created' => '09/20/2015', 'amount' => '18,000'], ['id' => '002', 'school_name' => 'Jose Cuevas', 'town' => 'ag', 'date_created' => '09/21/2015', 'amount' => '18,000'], ['id' => '003', 'school_name' => 'Joe Cuevas', 'town' => 'mc', 'date_created' => '09/22/2015', 'amount' => '18,000']]; //setting an attribute to a binded field $ds->field('field_enabled')->readonly(); $ds->field('emp_tax_rate')->readonly()->placeholder('FICA NOT REQUIRED'); $ds->field('email')->decoration("@uprm.edu"); //bind this ds to fields in a view with //the same name as this ds $ds->bindToView(); $f = \reasg\appBundle::create("test", "@assets"); \reasg\client_controller::importController('employee_controller', $f->js->child('employee.controller.js')->url); global $app_controller; $ui = $this->controller->client(); //$ui->showAlertError("This is big alert 2!"); $a = ['start_date' => '09/27/2015']; $ui->populateSelectorWithDataset("employee", $a); //$page->js->write("//hello jose"); //$o = \reasg\client_controller::when("employee.email")->changed()->val('jose.cuevas')->done(); //reasg_dev_dump($o,'$o'); //global $app_state; //reasg_dev_dump($app_state['current_interaction'], '$app_state'); $recordView = \reasg\ui_template::create("record.view"); $recordView->set("record_title", "Employee Record"); $page->body->write($recordView); //reasg_dev_dump($recordView); }
public function client() { global $ui_default_interaction, $ui_default_view; if (is_null($ui_default_interaction)) { $ui_default_interaction = new client_interaction(); $view = \reasg\ui_views::getDefaultView(); if (!is_null($view)) { $m = function () use($view, $ui_default_interaction) { error_log("here client commit 1"); $js = 'var init_interactions = ' . $ui_default_interaction->toJSON() . ";\n"; $js .= 'var promise = {success: undefined,failure: undefined, data: undefined};' . "\n"; $js .= 'rea_controller.backend.handleResponseJSON(init_interactions,promise);' . "\n"; $view->js_ready->write($js); error_log("here client commit to view 2"); $view->debug(); }; $this->on('default_view_commit', $m); } else { $m = function () use($ui_default_interaction) { global $app_controller; error_log("here client commit 2"); $app_controller->header('Content-Type', 'text/json'); $s = $ui_default_interaction->toJSON(); $app_controller->write($s); }; $this->on('app_send_output', $m); } } error_log("returning client"); return $ui_default_interaction; }
function bindToSelector($sel) { global $app_controller; $uid = $this->uid; $name = $this->name; $view = \reasg\ui_views::getDefaultView(); //$view->js_ready->write($js); $js = "var ds = ui_datasource_controller.createDataSourceWithObject('" . $this->name . "', " . $this->getHTML() . ");\n"; error_log("@bindToSelector {$sel}::default_view_commit ========="); $m = function ($view) use($uid, $name, $sel, $js) { error_log("@closure default_view_commit ========="); $s = "ui_datasource_controller.populateSelectorWithDataset(\"{$sel}\", ui_datasource_controller.getDatsourceWithName(\"{$name}\") );\n"; $view->js_ready->write($s); $view->js_payload->write($js); }; $app_controller->on('default_view_commit', $m); }