Git Product home page Git Product logo

sharp's People

Contributors

aguingand avatar b0rt avatar bramesposito avatar dvlpp avatar earboxer avatar ewatch avatar gdott9 avatar grahamcampbell avatar hdvinnie avatar insolita avatar israaraujo avatar klaasie avatar laravel-shift avatar lucastuzina avatar marcinlawnik avatar mdcass avatar mlajx avatar nathangiesbrecht avatar oddvalue avatar patrickepatate avatar ramon-piripono avatar remicollin avatar rokkay avatar sandervankasteel avatar smknstd avatar stylecibot avatar t2t2 avatar thenabeel avatar tylerrister avatar vootrunner avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sharp's Issues

Autocomplete field with create new function

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.

Authorizations for instance command make lot of queries

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';

Undesired filter behaviour when values array has 0 index defined

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):

image

And DOM shows this:

image

Notes:

  • Issue has started happening in latest version. Previously same code was working fine.
  • It happens when filter values array has index 0 defined (as shown in above code).

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'
        ];
    }
}

image
image

Bug in date component

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.

Needs better navigation solution

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

Custom message & redirect after save/update

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.

Dump data

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.

Validator vs Formatter

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!

SQLSTATE[23502] when trying to save list field

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

Date-DateTime-DateInterval and Range Filters

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

Change geolocation source

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 ?

Impossible to transform an existing embedded image (markdown)

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)

Dashboard error after updating to 4.1

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?

image

Config file:

<?php
return [
    'dashboards' => [
        'dashboard' => [
            'view' => \App\Sharp\Dashboard::class,
        ]
    ],
    'entities' => [
        ...
    ],
    'menu' => [
        [
            'label' => 'Dashboard',
            'icon' => 'fa-dashboard',
            'dashboard' => 'dashboard',
        ],
    ],
];

Thumbnail path wrong

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

Hide delete button, disable redirect, and ability to change path of sharp

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.

Incorrect request building for entityCommand for EntityListMultipleFilter

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

  1. Make any filter implemented EntityListMultipleFilter and attach it to some SharpEntitlyList
  2. Make EntityCommand with usage $params->filterFor("multifilter_name") and attach it to the SharpEntitlyList
    example
class 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();
    }
}
  1. Try to execute entity command and got error

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

Crash when user has not at least one entity access allowed

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.

Validation error spec changed

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)

Exception raised in a Command: multiple message boxes

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

SelectForm Multiple Checked Values

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?

imagen

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.

Need example for integrate custom controllers and views

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

I don't know where to put classes!

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.

Artisan commands to scaffold new classes?

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.

Display SharpEntityList or SharpForm in tab of SharpForm for hasOne and hasMany relationships

Use Cases

  • I have a 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
  • I have a 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 tab

Implementation Notes

I'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

Show dropdown of InstanceCommands on SharpForm when updating

Use Case

When updating an instance, it would be useful to be able to access instance commands.

Implementation

  • I envisage the commands would be defined in a buildFormConfig method on the SharpForm, and the same front-end element rendered which is used on an EntityList

Custom web route prefix (instead of /sharp)

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!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.