<!--
Copyright 2020 Netsyms Technologies.
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.
-->

<div class="page" data-name="machineeditor">

    <div class="navbar">
        <div class="navbar-bg"></div>
        <div class="navbar-inner">
            <div class="left">
                <a href="#" class="link icon-only back">
                    <i class="icon icon-back"></i>
                </a>
            </div>
            <div class="title">{{#if machineid}}Editing #{{machineid}}{{else}}Add Machine{{if}}</div>
        </div>
    </div>

    <div class="fab fab-extended fab-right-bottom color-green" id="save-fab">
        <a href="#" onclick="saveMachineEdits({{#if machineid}}'{{machineid}}'{{/if}})">
            <!-- Icons For iOS Theme -->
            <i class="icon f7-icons if-not-md">floppy_disk</i>
            <!-- Icons For MD Theme -->
            <i class="icon material-icons md-only">save</i>
            <div class="fab-text">Save</div>
        </a>
    </div>

    <div class="page-content">
        <form id="machineform" style="margin-bottom: 5rem;">
            <div class="list no-hairlines no-margin-top">
                <ul>
                    {{#each info}}
                    {{#js_if "this.type == 'select'"}}
                    <li>
                        <a class="item-link smart-select smart-select-init" id="smartselect-{{name}}" data-searchbar="true" data-searchbar-placeholder="Search">
                            <select name="{{name}}" class="machinefield" tabindex="{{tabindex}}">
                                {{#each options}}
                                <option value="{{value}}" {{#js_if "../value == this.value"}}selected{{/js_if}}>{{label}}</option>
                                {{/each}}
                            </select>
                            <div class="item-content">
                                <div class="item-inner">
                                    <div class="item-title">{{label}}</div>
                                </div>
                            </div>
                        </a>
                    </li>
                    {{else}}
                    <li class="item-content item-input">
                        <div class="item-inner">
                            <div class="item-title item-floating-label">{{label}}</div>
                            <div class="item-input-wrap">
                                {{#js_if "this.type == 'textarea'"}}
                                <textarea class="machinefield" rows="4" name="{{name}}" placeholder="" tabindex="{{tabindex}}">{{value}}</textarea>
                                {{else}}
                                <input class="machinefield" type="{{type}}" name="{{name}}" placeholder="" value="{{value}}" tabindex="{{tabindex}}">
                                <span class="input-clear-button machinefield-clear-button display-none"></span>
                                {{/js_if}}
                            </div>
                        </div>
                    </li>
                    {{/js_if}}
                    {{/each}}
                </ul>
            </div>
        </form>
    </div>

    <script>
        var machineid = "{{machineid}}";
    </script>
</div>