How do I create a search form that handles both text as well as diagram search input?

Here is the code that I had done before but that used X-editables and Bootstrap 4. I’m rewriting that whole site but this time using BSS, so I have recreate this functionality:

Old QuiverDatabase Video

It shows that you can search for diagrams. Just wondering how I should do this in BSS as a newbie. It does have a learning curve. I tried placing a form with rows and columns in it with a TextInput and a Button, but nothing comes out looking right. There is no search form already in the studio library. Please guide me as to what I should do to accomplish this simple task.

The thought hit me while typing this that I could just copy the essential structure of what I have in my old code, as long as it’s written in BSS and not JS-driven like most of the quiver editor (what I’m borrowing for my project).

Thanks.

Worked beautifully, I’m not sure what you mean @printninja. I just used custom code regions, however another way to do this is to use my export script mechanism id=“IncludeDjangoTemplate-diagram_search_order_by” on some element. I will try things this way for now. I needed a re-usable search “widget” which is why the background is transparent and there’s no navbar on the page. That would go into diagram_search_page.html which does do an #IncludeDjangoTemplate-databse-diagram_search.

I can’t figure out yet whether it’s better to use iframes or to just copy/paste or include templates. I will be using an iframe on the editor (for example including a stripped down editor for drawing the search input) though because its page I sort of kept as close as possible to quiver’s index.html as I could.

<html>

<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0, shrink-to-fit=no" />
    <title>AbstractSpacecraft</title>
</head>

<body style="background: transparent;">
    <div class="container-fluid">
        <div class="row">
            <div class="col">
                <h2>Diagram Search</h2>
                <div class="btn-group" role="group"></div>
            </div>
        </div>
    </div>
    <div class="container">
        <div class="row">
            <div class="col-md-6">
                <h4>Order By:</h4>
            </div>
            <div class="col-md-6">
                <div class="dropdown" style="display: inline-block;"><button class="btn btn-primary dropdown-toggle" aria-expanded="false" data-bs-toggle="dropdown" type="button">{{ order_text }}</button>
                    <div class="dropdown-menu">
                        <div>{% for order in orders %}
                            {% if order.0 != order_param %}
                            <li><a href="?ord={{ order.0 }}&amp;asc={{ ascending }}">{{ order.1 }}</a></li>
                            {% endif %}
                            {% endfor %}
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="row">
            <div>{% if ascending == &quot;true&quot; %}
                <a id="sort-direction-button" class="btn btn-primary" href="{% url &#39;diagram_search&#39; diagram_id %}?ord={{ order_param }}&amp;asc=false&amp;onetoone={{ one_to_one }}" style="margin-left: 20px;">
                    Ascending
                </a>
                {% else %}
                <a id="sort-direction-button" class="btn btn-primary" href="{% url &#39;diagram_search&#39; diagram_id %}?ord={{ order_param }}&amp;asc=true&amp;onetoone={{ one_to_one }}" style="margin-left: 20px;">
                    Descending
                </a>
                {% endif %}
                {% if one_to_one == &quot;1&quot; %}
                <a id="sort-direction-button" class="btn btn-primary" href="{% url &#39;diagram_search&#39; diagram_id %}?ord={{ order_param }}&amp;asc={{ ascending}}&amp;onetoone=0" style="margin-left: 20px;">
                    One-to-one Match
                </a>
                {% else %}
                <a id="sort-direction-button" class="btn btn-primary" href="{% url &#39;diagram_search&#39; diagram_id %}?ord={{ order_param }}&amp;asc={{ ascending }}&amp;onetoone=1" style="margin-left: 20px;">
                    Match Subgraph
                </a>
                {% endif %}

                <a id="search-button" class="btn btn-success" href="{% url &#39;diagram_search&#39; diagram_id %}?ord={{ order_param }}&amp;asc={{ ascending }}&amp;onetoone={{ one_to_one }}" style="margin-left: 20px;">
                    Search
                </a>
            </div>
        </div>
    </div>
    <hr />
    <div class="row">
        <div class="col">
            <div>{% for diagram in diagrams %}
                <div class="row">
                    <h3>{{ diagram.name }}</h3>
                    <ul class="nav nav-pills" style="display: inline-block;top: 10px;">
                        <li class="nav-item"><a class="nav-link btn btn-primary" href="#">
                                Usages <span class="badge badge-light">{{ diagram.usages }}</span></a></li>
                    </ul>
                    <div class="pull-right" style="display: inline-block;"><a class="btn btn-primary" href="{% url &#39;diagram_viewer&#39; rule.uid %}" target="_blank">
                            View
                        </a></div>
                </div>
                <hr style="border: 0;height: 0;border-top: 1px solid rgba(0,0,0,0.1);border-bottom: 1px solid rgba(255,255,255,0.3);" />
                {% endfor %}
            </div>
        </div>
    </div>
    <nav>
        <ul class="pagination">
            <li class="page-item"><a class="page-link" aria-label="Previous" href="#"><span aria-hidden="true">«</span></a></li>
            <li class="page-item"><a class="page-link" href="#">1</a></li>
            <li class="page-item"><a class="page-link" href="#">2</a></li>
            <li class="page-item"><a class="page-link" href="#">3</a></li>
            <li class="page-item"><a class="page-link" href="#">4</a></li>
            <li class="page-item"><a class="page-link" href="#">5</a></li>
            <li class="page-item"><a class="page-link" aria-label="Next" href="#"><span aria-hidden="true">»</span></a></li>
        </ul>
    </nav>
</body>

</html>
```o

As I wrote, I was not entirely clear on what you were trying to achieve, but I’m glad you were able to use custom code blocks to get the results you were after.

1 Like

I’m changing my mind again. I’m not liking how the BSS viewer shows the custom code, but I would like it show something. So I will change each of those code regions into a Django template include. What’s nice about that is I can insert any element with id IncludeDjangoTemplate-template_name and that would include an example say search result entry that kind of looks like the result, I could even insert an image of a diagram! I’m liking this approach much more.

The way to see things about what is in the custom code (even though you still cannot edit it with the drag and drop stuff) is to select the parts you want to see in the HTML window. This will then show you at least the Styles that are applied to it.

First click to select the Custom Code block in your Overview panel, then in the HTML window that block will be selected. Now open that selection to see the rest of the contents in the HTML window and click on the various parts. Any parts that have specific CSS/SCSS tied to them will change the Styles window to show you those ID’s / Classes.

Hope that helps! :slight_smile: