Screens
Overview #
Under Resource, there are 4 screens:
- ListScreen to perform record listing with admin table, filter box, action box
- DetailScreen to show a record in detail including relational information.
- UpdateScreen to perform update information of a record
- CreateScreen to create new record.
Under each screen, we have many components and the great thing is that you can access those components and make customization on your need. You also even replace the component with your own piece, just plug and play.
Access component #
You can access each component and change settings like following
class Customer extends Resource
{
protected function onCreated()
{
//Settings for adminTable()
$this->listScreen()->adminTable()
->tableSmall(true)
->rowClickToSelect(true);
//Set the type of glassBox inside list screen
$this->listScreen()->glassBox()
->type("primary");
//Change style and text of save button in update screen
$this->updateScreen()->saveButton()
->text("Save this")
->type("success");
}
}
Assign component #
Or you can even replace the component with your own class:
class Customer extends Resource
{
protected function onCreated()
{
$this->listScreen()->adminTable(
MyNewAdminTable::create()
);
}
}
ListScreen #
title #
Get/set the title of screen
$this->listScreen()->title("Resource name");
adminTable #
Get/set the admin table object
$this->listScreen()->adminTable()
The AdminTable is have all properties of Table widget and added following properties
Name | type | default | description |
---|---|---|---|
rowSelectField | RowSelect | Get/set the row select field, set null to turn off row select | |
rowActionsField | ActionsField | Get/set the row actions field, set null to turn off | |
rowClickToSelect | bool | true | Click to row to select that row |
rowClickToDetail | bool | false | Click to row to go to detail of the record |
rowClickToUpdate | bool | false | Click to row to edit the information of the record |
contextConditions | array | null | Set extra conditions for data to be shown on table |
relationTable #
Get/set the relation table object. The relation table will be shown when the resource is referred to from another resources.
$this->listScreen()->relationTable()
Relation Table has all properties of Table widget. Below are extra properties
Name | type | default | description |
---|---|---|---|
rowActionsField | ActionsField | Get/set the row actions field, set null to turn off |
glassBox #
Get/set the glass dropdown object
$this->listScreen()->glassBox()
The glass box is derived from Dropdown widget.
actionBox #
Get/set the actions dropdown object
$this->listScreen()->actionBox()
The action box is derived from Dropdown widget.
filterBox #
Get/set the filter dropdown object
$this->listScreen()->filterBox()
The filter box is derived from FormDropdown container.
createButton #
Get/set the create button object
$this->listScreen()->createButton()
The create button is derived from Button.
searchBox #
Get/set the search box object
$this->listScreen()->searchBox()
The search box is derived from TextBox.
DetailScreen #
title #
Get/set the title of screen
$this->detailScreen()->title("Detail information");
//Set anynomous function
$this->detailScreen()->title(function(){
return $this->data()["customerName"];
});
backButton #
Get/set the back button object
$this->detailScreen()->backButton()
The back button is derived from Button.
mainPanel #
Get/set the main panel object
$this->detailScreen()->mainButton()
The main panel is derived from Panel
highlights #
Set the highlights for Detail screen
$this->detailScreen()->highlights(function($id){
//$id is the id value of record that shown by detail screen
return [
OrderOfCustomerMetric::create(),
AnyWidget::create(),
];
});
bottom #
Set the bottom for Detail screen
$this->detailScreen()->bottom(function($id){
//$id is the id value of record that shown by detail screen
return [
OrderOfCustomerMetric::create(),
AnyWidget::create(),
];
});
data #
Get data of record that detail screen is showing
$this->detailScreen()->title(function(){
$data = $this->data();
return $data["customerName"];
})
getIDValue #
Get ID of record that detail screen is showing
$this->detailScreen()->title(function(){
$id = $this->getIDValue();
return $id;
})
UpdateScreen #
title #
Get/set the title of screen
//Set string
$this->updateScreen()->title("Resource name");
//Use anonymous function
$this->updateScreen()->title(function(){
return $this->data()["customerName"];
})
saveButton #
Get/set the save button object
$this->updateScreen()->saveButton()
The save button is derived from Button.
backButton #
Get/set the back button object
$this->updateScreen()->backButton()
The back button is derived from Button.
successNotification #
Get/set the notification object that will show when record is successfully updated.
$this->updateScreen()->successNotification()
The success notification is derived from Note.
failNotification #
Get/set the notification object that will show when record is failed to update.
$this->updateScreen()->failNotification()
The fail notification is derived from Note.
data #
Get data of record that update screen is working on
$this->updateScreen()->title(function(){
$data = $this->data();
return $data["customerName"];
})
getIDValue #
Get ID of record that update screen is working on
$this->updateScreen()->title(function(){
$id = $this->getIDValue();
return $id;
})
bottom #
Set the bottom for updateScreen
$this->updateScreen()->bottom(function($id){
//$id is the id value of record that shown by update screen
return [
OrderOfCustomerMetric::create(),
AnyWidget::create(),
];
});
CreateScreen #
title #
Get/set the title of screen
$this->listScreen()->title("Resource name");
successNotification #
Get/set the notification object that will show when record is successfully created.
$this->createScreen()->successNotification()
The success notification is derived from Note.
failNotification #
Get/set the notification object that will show when record is failed to create.
$this->createScreen()->failNotification()
The fail notification is derived from Note.
backButton #
Get/set the back button object
$this->createScreen()->backButton()
The back button is derived from Button. s
saveButton #
Get/set the save button object
$this->createScreen()->saveButton()
The save button is derived from Button.
saveAndContinueButton #
Get/set the save and continue button object
$this->createScreen()->saveAndContinueButton()
The save and continue button is derived from Button.
bottom #
Set the bottom for createScreen
$this->updateScreen()->bottom(function($id){
//$id is the id value of record that shown by create screen
return [
OrderOfCustomerMetric::create(),
AnyWidget::create(),
];
});
Get started with KoolReport
KoolReport will help you to construct good php data report by gathering your data from multiple sources, transforming them into valuable insights, and finally visualizing them in stunning charts and graphs.