Пример #1
0
 public function cities($values)
 {
     $ds = \reasg\ui_datasource::createDataset('cities');
     $cities = ['pr' => ['ag' => 'Aguadilla', 'ad' => 'Aguada', 'an' => 'Añasco', 'ar' => 'Arecibo', 'is' => 'Isabela', 'mc' => 'Moca', 'mg' => 'Mayagüez', 'sb' => 'Sabana Grande', 'sb' => 'San German', 'sj' => 'San Juan', 'ho' => 'Hormigeros', 'ya' => 'Yauco', 'po' => 'Ponce', 'ri' => 'Rincon', 'by' => 'Bayamon', 'hu' => 'Humacao', 'ut' => 'Utuado'], 'fl' => ['or' => 'Orlando', 'mi' => 'Miami', 'tp' => 'Tampa', 'kw' => 'Key West', 'js' => 'Jacksonville', 'th' => 'Tallahassee', 'fd' => 'Fort Lauderdale'], 'ny' => ['nyc' => 'New York City', 'bf' => 'Buffalo', 'bn' => 'Bronx', 'ab' => 'Albany', 'sy' => 'Syracuse', 'ro' => 'Rochester'], 'vi' => ['ri' => 'Richmond', 'vb' => 'Virginia Beach', 'nf' => 'Norfolk', 'wi' => 'Williamsburg', 'qa' => 'Quantico']];
     //this event may receive an optional "q" parameter with a state
     $k = isset($values['q']) ? $values['q'] : 'pr';
     if (!array_key_exists($k, $cities)) {
         $k = 'pr';
     }
     $ds->items['options'] = $cities[$k];
     $this->controller->sendDataSet($ds);
 }
Пример #2
0
 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);
 }
Пример #3
0
 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);
 }
Пример #4
0
 public function sendDataset($data)
 {
     global $app_state;
     $dsn = 'ds_' . uniqid();
     if (is_object($data) && is_a($data, '\\reasg\\ui_datasource')) {
         $ds = $data;
     } else {
         $ds = \reasg\ui_datasource::createDataset($dsn);
         if (is_array($data)) {
             $ds->setItems($data);
         }
     }
     $this->header('Content-Type', 'text/json');
     $this->write($ds);
     if ($app_state['commited']) {
         return;
     }
     return $this;
 }