<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
    <head th:replace="_fragments :: head('Generate Master Barcode')"></head>
    <body>
        <div class="container-fluid">
            <header class="row page-header" th:replace="_fragments :: page-header"></header>
            <main class="row page-main">
                <div class="col-sm">
                    <div th:replace="_notices :: page-notices"></div>
                    <h3>Generate Master Bundle</h3>
                    <!--item form starts-->
                    <form th:href="@{/generate-master-bundle/edit}"
                          method="POST"
                          th:object="${wrapper}"
                          th:fragment="masterBundleFragment"
                          id="masterBarcodeApp">
                        <div class="bg-light p-3 mb-3">
                            <div class="form-row">
                                <div class="col-sm-3">
                                    <bundle-search
                                            v-on:bundle-select="onBundleSelect"
                                    ></bundle-search>
                                </div>
                            </div>
                        </div>
                        <div class="bg-light p-3 mb-3">
                            <h6>Bundles</h6>
                            <bundle-table
                                    v-bind:bundles="bundles"
                                    v-on:bundle-remove="removeBundle"
                            ></bundle-table>
                            <div class="alert alert-danger" v-if="hasDuplicates()">Duplicate Items Selected</div>
                        </div>
                        <div>
                            <button class="btn btn-primary" type="submit"
                                    v-bind:disabled="hasDuplicates() || bundles.length === 0">
                                Submit
                            </button>
                            <a th:href="@{/cutting/generate-master-barcode}" class="btn btn-light">Cancel</a>
                        </div>
                    </form>
                    <script th:inline="javascript">
                        window.ctp.wrapper = [[${wrapper}]];
                    </script>
                    <script th:src="@{/js/vendor/compressor.min.js}"></script>
                    <script th:src="@{/js/generate-master-barcode.js}"></script>
                </div>
            </main>
        </div>
        <div th:replace="_fragments :: page-footer-scripts"></div>
    </body>
</html>