Commit 5f822182 authored by Bernhard Baumrock's avatar Bernhard Baumrock

Add new file

parent 0ce62c8d
<?php
class ProcessSkyDashboard extends Process {
public function ___execute() {
$form = $this->modules->get('InputfieldForm');
bd($this->input->post);
$field = $this->modules->get('InputfieldMarkup');
$field->label = 'Table';
$field->value = $this->renderTable();
$field->columnWidth = 50;
$form->add($field);
$field = $this->modules->get('InputfieldMarkup');
$field->label = 'Chart';
$field->value = $this->renderChart();
$field->columnWidth = 50;
$form->add($field);
$fieldset = $this->modules->get('InputfieldFieldset');
$fieldset->label = 'Add Skyscraper';
//$fieldset->collapsed = Inputfield::collapsedYes;
$field = $this->modules->get('InputfieldText');
$field->name = 'Name';
$field->columnWidth = 33;
$fieldset->add($field);
$field = $this->modules->get('InputfieldText');
$field->name = 'Height';
$field->columnWidth = 33;
$fieldset->add($field);
// see InputfieldPage.module for all available options
$field = $this->modules->get('InputfieldPage');
$field->inputfield = 'InputfieldSelect';
$field->findPagesSelector = 'template=city';
$field->labelFieldName = 'title';
$field->name = 'City';
$field->columnWidth = 34;
$fieldset->add($field);
$button = $this->modules->get('InputfieldSubmit');
$button->value = 'Save';
$button->icon = 'floppy-o';
$fieldset->add($button);
$form->add($fieldset);
return $form->render();
}
private function renderTable() {
$out = '';
$table = $this->modules->get('MarkupAdminDataTable');
$table->setSortable(false); // sorting is done on the client side so we disable it to prevent misunderstandings
$table->headerRow(['Skyscraper', 'Added']);
// $table->addClass('uk-table-striped'); // looks ugly imho but stays here to show it could be done
// see MarkupAdminDataTable.module
foreach($this->pages->find("template=skyscraper,limit=5,sort=-created") as $sky) {
$table->row([$sky->title => $sky->editUrl, date("d.m.Y H:i:s", $sky->created)]);
}
$out .= $table->render();
return $out;
}
private function renderChart() {
$out = '';
// this method works only on non-ajax fields!
// when the field is loaded via ajax the scripts would not get injected because the page header and script-tags have already been rendered
$this->config->scripts->add('https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.7.1/Chart.bundle.min.js');
$this->config->scripts->add($this->config->urls->siteModules . $this->className() . '/skyscraperchart.js');
$out = '<canvas id="chart"></canvas>';
return $out;
}
}
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment