Cards
Learn how to build custom cards for your Djing application.
Overview
Cards are similar to resource tools, but are small, miniature tools that are typically displayed at the top of your dashboard, resource index, or resource detail pages. In fact, if you have used Djing metrics, you have already seen Djing cards. Custom Djing cards allow you to build your own, metric-sized tools.
Defining Cards
Cards may be generated using the djing:card
Artisan command. By default, all new cards will be placed in the djing_components
directory of your application. You can generate a card using the djing:card
command:
commander djing:card HelpCard
Djing cards include all of the scaffolding necessary to build your card. Yuu have to then add CardServiceProvider class to djing_admin.config.app.providers list.
from djing_admin.app.Providers.DjingServiceProvider import DjingServiceProvider
from djing_components.HelpCard.CardServiceProvider import CardServiceProvider
app = {
"providers": [
DjingServiceProvider,
CardServiceProvider
],
}
Registering Cards
Djing cards may be registered in your resource’s cards
method. This method returns an array of cards available to the resource. To register your card, add your card to the array of cards returned by this method:
from djing.core.Http.Requests.DjingRequest import DjingRequest
from djing_admin.app.Djing.Resource import Resource as DjingResource
from djing_components.HelpCard.HelpCard import HelpCard
class User(DjingResource):
# ...
def cards(self, request: DjingRequest):
return [
HelpCard(),
]
Last updated