code16 / sharp Goto Github PK
View Code? Open in Web Editor NEWLaravel 10+ Content management framework
Home Page: https://sharp.code16.fr/
License: MIT License
Laravel 10+ Content management framework
Home Page: https://sharp.code16.fr/
License: MIT License
Let's say we want to create a new book with an author that we select with an autocomplete field, it searches an author table for the correct author. If it does not find the author of the book we dont want to abort and first create a new author then go back and start over to create the book. Is there anyway to solve this with Sharp? Ideally there would be an autocomplete field that also takes input that does not exist in the source and handles it in the update method by creating a new author before saving. A bit like wordpress taxonomy tags work I suppose.
https://github.com/code16/sharp/blob/master/docs/commands.md
public function authorizeFor($instanceId): bool
{
return Spaceship::findOrFail($instanceId)->owner_id == sharp_user()->id;
}
make query for each instance in list; (if we show list with 50 items per page, it calls 50 queries)
If we have got access to instance directly, instead of instanse id, queries will be decreased.
public function authorizeFor($instance): bool
{
return $instance->owner_id == sharp_user()->id;
// Even return $instance->parent->owner->id == sharp_user()->id;
// if we build query with('parent') for entity list
}
also that bring ability to show filter conditionaly, for example return $instance->state == 'ready';
Problem:
I have a filter:
class Foo implements EntityListFilter
{
public function label()
{
return 'Status';
}
public function values()
{
return [
0 => 'Inactive',
1 => 'Active',
];
}
}
It causes undesired behaviour; displays value on filter label even when filter is not selected (e.g. first page load), but records displayed are fine and do not have any filter applied (desired behaviour):
And DOM shows this:
Notes:
Support:
On the other hand, I have similar filter, it works fine.
class Bar implements EntityListFilter
{
public function label()
{
return 'Status';
}
public function values()
{
return [
1 => 'Available',
2 => 'Not Available'
];
}
}
Hello,
For the date component, I set a step time of 5 minutes with this config :
SharpFormDateField::make("startday") ->setHasDate(false) ->setHasTime(true) ->setStepTime(5) ->setDisplayFormat('HH:mm') ->setLabel("Début de journée")
In that case, everything works fine except when I choose '23' hours. In that case minutes are always stuck to 0 and not displaying the correct minutes range.
Even when searchable
is false
...
Is exists way to show form field with dependency based on action type - for create or for update only?
For example we have the Post entity;
Post hasMany comments
Post has Many user rates
We can create CommentEntityList and PostRate entityList with default filter by post_id and show post-related lists. we don't show this lists in menu, because its not independent. And there is only one way to create links between Posts and related staff - it is create actions like "show post comments", "show user rates" for post, and "go to post" for sub-entities. And it is not comfortable solution, because in action menu mixed view/navigation links and true action commands. Action list can be very large for rich entities like an user, post, product. Also we hasn't opportunity for breadcrumbs building
Other case - that is for some entities only one list is not enough. Some times we need to show lists with different grouped items, or with different columns
After a crop on a sharp upload, thumbnails are re-created BUT browser cache hides it.
Hi,
Is there any elegant way to define a custom message which when flashed to the session (or similar) will display on the resulting page.
The scenario is to provide additional information after the creation of an entity. It might be useful to specify the redirect path after creating/updating too.
Hi, im using Sharp for a project, its a powerful tool but sometimes i feel a bit lost. I dont know how to to dump data after create/update a record. I tried with dd(), dump() and barryvdh/laravel-debugbar package. I have .env debug to true but nothings works.
Thanks in advance.
Hi,
From what I found out, when we're using a Validator, it's triggered before it hits SomeFormatter::fromFront()
. Is this intended? It has occurred to me that this causes problem when trying to validate existence (using Laravel's Exists rule) in an autocomplete field. It appears that the the data that the Validator's got are in array instead of in id
like it's supposed to (post formatted).
I managed to overcome the issue but it's quite hacky and not really elegant. Is there a better solution?
Thanks!
Hello there,
I try to setup a "Form field: List" to upload multiple pictures for a model. I setup Sharp upload engine as described in the manual (Great job by the way !) but when I try to save the pictures it gives me this :
SQLSTATE[23502]: Not null violation: 7 ERROR: null value in column "id" violates not-null constraint DETAIL: Failing row contains (null, App\Models\Hotel, 16, null, null, null, local, null, {"legend":null}, null, 2018-08-31 13:42:54, 2018-08-31 13:42:54). (SQL: insert into "filesmanager" ("model_id", "model_type", "id", "custom_properties", "updated_at", "created_at") values (16, App\Models\Hotel, , {"legend":null}, 2018-08-31 13:42:54, 2018-08-31 13:42:54) returning "id")
I investigate to try to solve this bu it seems that MorphMany relationship ahev some trouble in my case, here's the ralation I setup for my Hotel model :
{
return $this->morphMany(FileManager::class, "model")
->where("model_key", "pictures")
->orderBy("order");
}
Did you already encounter this ?
Thx
If we use a boolean value for the state
, and when this value is 0
, the Entity List crashes (no console message, but no item displayed)
Is there simple way for create filters with date/datetime input or date interval (for select entities created between startDate - endDate)
and also range filters for ex. for select entites with price between minPrice and maxPrice
Hello,
Not a bug at all but facing the GMaps geolocation / billing issues, is there a way to use another geolocation service ?
OSM / Nominatim for exemple ?
local.ERROR: local:data/Spaceship/40/markdown/1181477-in_extremis-c-diogenes-verlagag-zurich-cles-cahiers-dessines-paris2018_p48-49.jpg {"userId":1,"email":"[email protected]","exception":"[object] (Illuminate\Contracts\Filesystem\FileNotFoundException(code: 0): local:data/Spaceship/40/markdown/1181477-in_extremis-c-diogenes-verlagag-zurich-cles-cahiers-dessines-paris2018_p48-49.jpg at /Users/philippe/code/code16/sharp/saturn/vendor/laravel/framework/src/Illuminate/Filesystem/FilesystemAdapter.php:109, League\Flysystem\FileNotFoundException(code: 0): File not found at path: local:data/Spaceship/40/markdown/1181477-in_extremis-c-diogenes-verlagag-zurich-cles-cahiers-dessines-paris2018_p48-49.jpg at /Users/philippe/code/code16/sharp/saturn/vendor/league/flysystem/src/Filesystem.php:388)
Hi,
I've just updated to the latest tag from 4.0 and I'm getting some js errors and my dashboard it broken.
I've followed the upgrade instructions and altered the config for the menu and dashboard. If I go to http://laravel.test/sharp/api/dashboard/dashboard in the browser I get the expected json response but for some reason the dashboard is attempting to load http://laravel.test/sharp/api/dashboard.
Any ideas what's going on here?
Config file:
<?php
return [
'dashboards' => [
'dashboard' => [
'view' => \App\Sharp\Dashboard::class,
]
],
'entities' => [
...
],
'menu' => [
[
'label' => 'Dashboard',
'icon' => 'fa-dashboard',
'dashboard' => 'dashboard',
],
],
];
Hi,
Since this commit 2f8140d all thumbnail urls have stopped working.
The issue seems to be that the images were previously stored in the public directory public/thumbnails/...
and so were served without any problems. Now they are stored under storage/public/thumbnails/...
.
I do have the symlink set up to map storage/public/
to public/storage/
so if I add "storage" to the url it loads the image but the url returned from the thumbnail method doesn't contain it so the image isn't loaded.
e.g
URL returned from the thumbnail method that 404s:
http://laravel.test/thumbnails/images/300-300/image.jpeg
URL with "storage" added that works:
http://laravel.test/storage/thumbnails/images/300-300/image.jpeg
How are you handling this in your projects? Is there a new step missing from the readme?
Thanks
Hey! I love the project, but there are a few features that I would like to get opinions on. I would like to have a way to hide the delete button on a form, the ability to disable redirecting once a form is submitted, and the ability to change the default path of /sharp to anything I would like. I have forked sharp and have made all of these changes on my own branch. But I wanted to get opinions on it before I submitted a pull request for those features.
Description:
Error occured in https://github.com/code16/sharp/blob/master/src/EntityList/EntityListQueryParams.php#L183
Because request data for multiple filter parameter contains array of values instead of comma separated values like for list
Seems this place https://github.com/code16/sharp/blob/master/src/EntityList/EntityListQueryParams.php#L77
is bug source, because for EntityList request fetched via request()->all()
but for EntityCommand request fetched via request("query")
and it needs to prepare in valid format
Steps for reproduce
$params->filterFor("multifilter_name")
and attach it to the SharpEntitlyListclass ReadMarkAll extends EntityCommand
{
...
public function execute(EntityListQueryParams $params, array $data = []): array
{
$models = Model::orderBy($params->sortedBy() ?? 'created_at', $params->sortedDir() ?? 'desc');
if (!empty($params->filterFor("level"))) {
$models->whereIn("level", Arr::wrap($params->filterFor("level")));
}
...
$models->update(['is_read' => true]);
return $this->reload();
}
}
mb_strpos() expects parameter 1 to be string, array given
I can make PR with fix, but not sure in best way. As first, we can to make additional query formatting when $queryPerfix not null, in other way, we can to add filter value formatting in setFilterValue method https://github.com/code16/sharp/blob/master/src/EntityList/EntityListQueryParams.php#L211
But may be it require fixes on client-side
Hello,
For my app I'm using this package to setup roles & permissions :
https://github.com/spatie/laravel-permission
If the user has no access to at least a single entity, the system fails.
In Http\Composers\MenuViewComposer
line 23 :
$category = new MenuCategory($categoryConfig);
If the user has no acces to an entity, $category->entities
is then set to NULL instead of an empty collection. The sizeof on the next line is causing the crash.
As i see https://github.com/code16/sharp/blob/master/resources/views/partials/_menu.blade.php
Custom menu items is not supported ? (For foreighn sites, with target="_blank" option and also for non-sharp routes)
To be compliant with Laravel 5.5 and backward compatible with 5.4, we have to change the way validation errors (422) are sent:
errors : {
name: [
"The name is required"
]
}
(Simply add an error
top key)
The height of the crop dialog depends on the height of the upload file itself: it shouldn't.
Hi, noticed in this line you guys forgot to add "container" class:
event when not wanted (no crop ratio sent)
In the Entity List, the search field input has a box-shadow
, only when unfocused. It shouldn't.
2 or more message boxes are shown piled when an exception is raised by a Command.
Saturn use case: spaceship > "Send a text message", and type the string "error" in the message
field
branch: fix/multiple-error-messages
Hello again, I have a form with days of the week in a selection field with setMultiple. When I modify the registry, I want to be able to mark or unmark the days of the week but, by default, all are unchecked, I can not find any way to do it. I searched the docs but I have not seen any method to select the default fields. Maybe i'm forgotten something? I want to select the corresponding values when i retrieve the model. Can i do this with a transformer?
Here's my code:
Array with days of the week
$diasSemana = [ 1 => __('forms.actividad.dias.lunes'), 2 => __('forms.actividad.dias.martes'), 3 => __('forms.actividad.dias.miercoles'), 4 => __('forms.actividad.dias.jueves'), 5 => __('forms.actividad.dias.viernes'), 6 => __('forms.actividad.dias.sabado'), 7 => __('forms.actividad.dias.domingo'), ];
Add field
->addField( SharpFormSelectField::make("dias_semana", $diasSemana) ->setLabel(__('forms.actividad.dias.semana')) ->setMultiple() ->setDisplayAsList() )
Thanks in advance.
You make excellent job, and your api covered many use-cases, but sometimes more complex logic is neccessary. For example i have api-controller and vue-components based on vue-simple-calendar for adding events, custom quiz-constructor, and now i looking for way to inject it in the sharp layout
Hi guys, any plan to support the new Laravel 5.8?
Sorry i didn't know where to ask this question, but i don't konw how to start building dashboard (Lists, Forms) .. on the docs there is no mention of where should i create those classes ! Help Me.
why only text and password types supported?
What about email, url, tel, color?
Are there any plans to implement artisan commands to scaffold new classes? I'm just getting started with Sharp and I feel like some generators would save a lot of time and keystrokes.
User
with a hasOne
relation to a Profile
model - it would be useful to be able to display the SharpForm
for the profile in a tab on the User
's SharpForm
and have it POST
to the Profile
's SharpForm
User
with a hasMany
relation to a SocialAuthentication
model it would be useful to be able to display the SharpEntityList
filtered by the user_id
for the SocialAuthentication
model in a tabI'm unsure at this point whether this would require major changes, especially on the front-end, or whether it would actually be fairly easy.
I envisage the closure passed to the addTab
method on the SharpForm
class called from the buildFormLayout
would return either a SharpForm
class or SharpEntityList
class, both accepting parameters
which define in the first case, the instance being updated, and in the second case, the parameters to apply to existing filters on the SharpEntityList
Add a 200ms (to be tested) debounce to avoid API calls on each keystroke
Seems that it's working for Text fields, but not for Upload: previously uploaded file stays.
When updating an instance, it would be useful to be able to access instance commands.
buildFormConfig
method on the SharpForm
, and the same front-end element rendered which is used on an EntityList
Hi,
Let me start by thanking u guys. What an awesome package! I just started using it and it works seamlessly so far. Thus, I'll try to help anyway I can.
It would be helpful to have an ability to change the web route prefix (currently hardcoded to: /sharp
) to something else, probably configurable through config/sharp.php
.
Let me know what u think about this, I may be able to help out if it's not within your plans.
Thanks!
Old spec:
values: {
1: "My label",
2: "My label",
}
New spec:
values: [
{id: 1, label: "My label"},
{id: 2, label: "My label"},
]
Here's the command's API return:
{"action":"info","message":"L'importation est en cours..."}
But nothing is displayed on the front.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.