Skip to content
This repository has been archived by the owner on Nov 7, 2019. It is now read-only.

Maked table depending on blueprint values #8

Merged
merged 3 commits into from
Nov 17, 2017

Conversation

Piterden
Copy link

@Piterden Piterden commented Mar 8, 2017

No description provided.

@rhukster
Copy link
Member

I'll take a look at this soon.. thanks.

@rhukster
Copy link
Member

I like this but i want to investigate a bit more to make it a handle the sort option a bit better.

@Piterden
Copy link
Author

Yes, I actually wrote it for my custom data collection, not the default of your plugin.

@rhukster
Copy link
Member

Yah i like the idea of making the list more blueprint-driven. However, I think we can actually put custom fields in the blueprint YAML that the list can use. Ie, the 'sortable', 'searchable', 'width' options etc.

@Piterden
Copy link
Author

Piterden commented Mar 14, 2017

We could do even like so:

  fields:
    published:
      type: toggle
      label: Published
      highlight: 1
      default: 1
      options:
        1: PLUGIN_ADMIN.YES
        0: PLUGIN_ADMIN.NO
      validate:
        type: bool
        required: true
      # We could add
      column:
        type: editable # Just for example
        width: 18
        # And so on...

@mahagr
Copy link

mahagr commented Nov 15, 2017

I've done the same in my feature branch, though I didn't store this information in the form part but into a separate configuration.

@mahagr mahagr changed the base branch from develop to feature/multiple November 17, 2017 08:10
@mahagr mahagr merged commit 8060375 into trilbymedia:feature/multiple Nov 17, 2017
@Piterden
Copy link
Author

👍

@Piterden Piterden deleted the patch-1 branch November 17, 2017 08:12
@mahagr
Copy link

mahagr commented Nov 17, 2017

I'm going to make a few changes.. :)

@Piterden
Copy link
Author

yes - this is just a sketch ;)

@mahagr
Copy link

mahagr commented Nov 17, 2017

@Piterden I think you like the changes I made. It's still pretty much work in progress, but I have a branch that added support for multiple directories. It also added new config section to the blueprints in order to automate and customize listing page.

I reverted your changes in the original file -- I'm now using new folder structure, which allows easier customization.

To test this out, just add following code to user/blueprints/flex-directory/clients.yaml

title: Clients
description: Client list.
type: flex-directory

config:
  admin:
    list:
      fields:
        name:
          link: edit
        company:
        email:
        phone:
          width: 15
        zip:
          width: 10
  data:
    storage: user://data/directory/clients.yaml

form:
  validation: loose

  fields:
    id:
      type: text
      label: Id
      validate:
        required: true
    name:
      type: text
      label: Full Name
      validate:
        required: true
    company:
      type: text
      label: Company
    email:
      type: email
      label: Email Address
      validate:
        required: true
    phone:
      type: text
      label: Phone Number
    zip:
      type: text
      label: Zip Code
    ip:
      type: text
      label: IP Address

After that just edit user/config/plugins/flex-directory.yaml file by hand and add following:

directories:
  - blueprints://flex-directory/clients.yaml

For frontend you need user/pages/02.directory/flex-directory.md:

---
cache: false
---

# Directories

And also template file themes/[YOUR_THEME]/templates/flex-directory/types/clients.html.twig:

{% set directory = grav.flex_directory.directory(type) %}
{% set data = directory.collection.getData().toArray() %}

<div id="flex-directory">
    <ul class="list">
        {% for entry in data %}
            <li>
                <div class="entry-details">
                    <h3>{{ entry.name }} <small>&lt;{{ entry.email }}&gt;</small></h3>
                    <p>Company: {{ entry.company }}</p>
                    <p>ZIP: {{ entry.zip }}</p>
                </div>
            </li>
        {% endfor %}
    </ul>
</div>

If you add multiple types, both admin and site will have types list as landing page. :)

Happy testing.

PS. This only works in my feature/multiple branch.

@Piterden
Copy link
Author

I have one not a bad example in Vue. For the inspiration.
https://gitlab.com/Piterden/good-motherfucker/blob/piterden/app2/src/components/Filters/Filters.vue#L2

@8book
Copy link

8book commented Mar 10, 2018

Hello!

I am using the Flex Directory plugin with the modifications to create multiple entries, I found AMAZING, I was interested in this option. Much obliged!

But now you have an old problem with the image field again. It gives the following error:
Call to undefined method Grav \ Plugin \ FlexDirectory \ AdminController :: data ()

I'm using:
Grav: Grav v1.4.0 - Admin v1.7.0

Form Yaml

thumbnail:
       type: file
       label: Thumbnail
       destination: 'user / data / directory / files'
       multiple: true

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants