Skip to content

drago-ex/application

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

335 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Drago Application

The Drago Extension is a package built on top of the Nette Framework, designed to provide several useful components for your web applications. Below are the classes in the extension and how you can use them.

License: MIT PHP version Coding Style

Requirements

  • PHP >= 8.3
  • Nette Framework
  • Composer
  • Bootstrap
  • Naja

Installation

composer require drago-ex/application

Project files

File copying is handled automatically by drago-ex/project-installer, which must be installed in your project. Without it, copy the files manually according to the copy section in this package's composer.json. To skip this package, set "skip": true under extra.drago-project.packages.<package-name> in your root composer.json.

Check if there is a pair signal receiver and name (default is edit).

$this->getSignal();

Is AJAX request?

Shorter method in control.

$this->isAjax();

Retrieves a form component by its name.

$form = $this['factory'];
$submitButton = $this->getFormComponent($form, 'submit');
$submitButton->setCaption('Edit');

Form factory with a custom form class

Use Drago\Application\UI\Factory when you want a typed factory for another form class, for example ExtraForms from drago-ex/form.

use Drago\Form\ExtraForms;

/**
 * @extends \Drago\Application\UI\Factory<ExtraForms>
 */
readonly class Factory extends \Drago\Application\UI\Factory
{
	protected function createForm(): ExtraForms
	{
		return new ExtraForms;
	}
}

Base template class extending Nette Template.

It is used in the bow of presenters or control

/**
 * @property-read Drago\Application\UI\ExtraTemplate $template
 */
class Presenter {}

In Latte, we will use these macros to insert into the template, which will tell us the variables and types that can be used by default in the template.

{templateType Drago\Application\UI\ExtraTemplate}
{varType Drago\Application\UI\Flashes[] $flashes}

<div n:foreach="$flashes as $flash" n:class="flash, $flash->type">{$flash->message}</div>

Flash message alert type

Toast - Bootstrap and naja component for flash messages

JavaScript setup

Since the package is installed via Composer, add the following to your package.json:

{
  "type": "module",
  "dependencies": {
    "drago-application": "file:vendor/drago-ex/application"
  }
}

Then run npm install.

import ToastHandler from 'drago-application/bootstrap-toast';

Using toast in a latte template

{include 'path/to/@toast.latte', flashes => $flashes}

About

📣 Extension for Nette Framework, providing reusable UI components, alert types, and flash message handling.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors