Tools For Better Developers

News: 2022 Jan 14 - 28

2022 January News

6 months ago ∙ 2 minutes read

Last two weeks were about implementing initial version of an Osm Admin grid, integrating it seamlessly with the editing form, and enabling mass-editing of multiple objects.

After finishing it, I realized that Osm Admin had become bigger than Osm Framework! To keep up, I started writing docs for it.

And now, you have a step-by-step guide for creating a project, adding Osm Admin to it and a practical example of an admin area that you can copy to your project and try it out locally.

More details:

Osm Admin v0.1.5

Diff

Admin User Interface

Finally, I've got the initial version of the user interface working. Yes, I know, a lot is yet to be implemented, and yet, the transition of seeing some exception stack trace into a page that works is huge!

And I've put a lot of effort into polishing small details. For example:

  • not only grid rows, but also Create and Edit buttons, are actually links that you can open in a new tab;
  • if you click outside a checkbox or a link, there is a high chance it will still work, thanks to property handling of a cell surrounding it;
  • filter URLs avoid "ugly" URL encoding by only using characters that don't require encoding;
  • ... and more.

Here is how it works (since I shot this screencast, it's got even better :) ):

For more details, read the whole article. Or even better, add the code sample to a local project and try it out in a browser!

Grid Attributes

Define available grid columns using [#Grid\*] property attributes, and make some of them visible using [Grid] class attribute:

/**
 * @property string $sku #[Grid\String_('SKU', edit_link: true), ...]
 * @property string $title #[Grid\String_('Title', edit_link: true), ...]
 * @property ?string $description #[Grid\String_('Description'), ...]
 * @property int $qty #[Grid\Int_('Quantity'), ...]
 */
#[Grid(['sku', 'title', 'qty']), ...]
class Product extends Object_
{
    ...
}   

Grid Model

Internally, the grid attributes are parsed into the data schema:

global $osm_app;

$grid = $osm_app->schema
    ->classes[Product::class]
    ->interfaces['table_admin']
    ->grid;

$titleColumn = $grid->columns['title'];

Documentation

I started writing documentation for Osm Admin:

I suspect that it will evolve with time, but hey, show me someone who wrote the perfect docs in one sit!

osm.software Website v0.4.7

Diff

There a new blog post about mass-editing feature in Osm Admin.

I've also fixed a couple of bugs. One was untested multi-year blog filter markup, and another was rendering incorrect links in the documentation sidebar.


I'm just getting started, and a lot more features are yet to come!

If you've enjoyed reading this, follow me on Twitter and be the first to know.