<commit_before><link rel="import" href="armor-item.html">

<dom-module id="armor-list">
    <style>
        .armor-items {
            overflow: auto;
            min-width: 300px;
            min-width: 500px;
        }

        ul {
            list-style: none;
            padding-left: 15px;
            padding-right: 15px;
        }

        li + li {
            border-top: solid 1px #666;
        }

        .add-armor {
            padding: 0px 15px 15px 15px;
        }

        table {
            color: #888;
        }

    </style>

    <template>
        <iron-signals
            on-iron-signal-fbupdate="_updateArmor">
        </iron-signals>

        <div style="padding:20px">
        <paper-material elevation=5 class="armor-items">
            <ul>
                <table width=100%><tr>
                    <td>Armor Item</td>
                    <td width=80 align=center>Armor</td>
                    <td width=80 align=center>Weight</td>
                    <td width=50 align=right></td>
                </table>
                <template id="armorList" is="dom-repeat" items="{{armor}}" as="item">
                    <li>
                        <armor-item
                            name="{{item.name}}"
                            armor="{{item.armor}}"
                            weight="{{item.weight}}"
                            key="{{item.__firebaseKey__}}">
                        </armor-item>
                    </li>
                </template>
            </ul>
            <paper-icon-button icon="add-circle" title="test" on-click="toggle">blah</paper-icon-button>
            <iron-collapse id="collapse">
            <div class="add-armor">
                <form is="iron-form" id="aform">
                    <paper-input id="name_field" name="name" label="Name" required></paper-input>
                    <paper-input id="armor_field" type="number" name="armor" label="Armor Bonus" required></paper-input>
                    <paper-input id="weight_field" type="number" name="weight" label="Weight"></paper-input>
                    <paper-button id="add_but" raised on-tap="_handleSubmit">Save</paper-button>
                    <div class="output"></div>
                </form>
            </div>
            </iron-collapse>
        </paper-material>
    </div>
    </template>

</dom-module>



<script>
    Polymer({
        is: "armor-list",

        _redraw: function() {
            this.$.armorList.render();
        },

        properties: {
            scroll: "true",
            armor: {
                type: Array,
                notify: true
            }
        },

        _updateArmor: function(e) {
            this.armor = app.$.armor.fbData;
            this._redraw();
        },

        _handleSubmit: function(e) {
            var entry = this.$.aform.serialize();
            var apparmor = app.$.armor.$.ref;
            apparmor.add(entry);

            this.$.armor_field.value = "";
            this.$.name_field.value = "";
            this.$.weight_field.value = "";
        },

        toggle: function() {
            this.$.collapse.toggle();
        }

    });
</script>
<commit_msg>Armor now won't submit without required fields<commit_after><link rel="import" href="armor-item.html">

<dom-module id="armor-list">
    <style>
        .armor-items {
            overflow: auto;
            min-width: 300px;
            min-width: 500px;
        }

        ul {
            list-style: none;
            padding-left: 15px;
            padding-right: 15px;
        }

        li + li {
            border-top: solid 1px #666;
        }

        .add-armor {
            padding: 0px 15px 15px 15px;
        }

        table {
            color: #888;
        }

    </style>

    <template>
        <iron-signals
            on-iron-signal-fbupdate="_updateArmor">
        </iron-signals>

        <div style="padding:20px">
        <paper-material elevation=5 class="armor-items">
            <ul>
                <table width=100%><tr>
                    <td>Armor Item</td>
                    <td width=80 align=center>Armor</td>
                    <td width=80 align=center>Weight</td>
                    <td width=50 align=right></td>
                </table>
                <template id="armorList" is="dom-repeat" items="{{armor}}" as="item">
                    <li>
                        <armor-item
                            name="{{item.name}}"
                            armor="{{item.armor}}"
                            weight="{{item.weight}}"
                            key="{{item.__firebaseKey__}}">
                        </armor-item>
                    </li>
                </template>
            </ul>
            <paper-icon-button icon="add-circle" title="test" on-click="toggle">blah</paper-icon-button>
            <iron-collapse id="collapse">
            <div class="add-armor">
                <form is="iron-form" id="aform">
                    <paper-input id="name_field" name="name" label="Name" required></paper-input>
                    <paper-input id="armor_field" type="number" name="armor" label="Armor Bonus" required></paper-input>
                    <paper-input id="weight_field" type="number" name="weight" label="Weight"></paper-input>
                    <paper-button id="add_but" raised on-tap="_handleSubmit">Save</paper-button>
                    <div class="output"></div>
                </form>
            </div>
            </iron-collapse>
        </paper-material>
    </div>
    </template>

</dom-module>



<script>
    Polymer({
        is: "armor-list",

        _redraw: function() {
            this.$.armorList.render();
        },

        properties: {
            scroll: "true",
            armor: {
                type: Array,
                notify: true
            }
        },

        _updateArmor: function(e) {
            this.armor = app.$.armor.fbData;
            this._redraw();
        },

        _handleSubmit: function(e) {
            var entry = this.$.aform.serialize();
            if(!this.$.aform.validate()) return;
            var apparmor = app.$.armor.$.ref;
            apparmor.add(entry);

            this.$.armor_field.value = "";
            this.$.name_field.value = "";
            this.$.weight_field.value = "";
        },

        toggle: function() {
            this.$.collapse.toggle();
        }

    });
</script>

{'fraction_non_alphanumeric': 0.14536146447409246, 'fraction_numerical': 0.011169717654359293, 'mean_word_length': 1.2652846099789177, 'pattern_counts': {'":': 0, '<': 107, '<?xml version=': 0, '>': 107, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '649875', 'n_tokens_mistral': 1922, 'n_tokens_neox': 1790, 'n_words': 312}