<commit_before><!DOCTYPE html>

<html xmlns:th="http://www.thymeleaf.org" th:replace="~{fragments/layout :: layout (~{::body},'hello')}">
    <body>
        <div class="container">
            <h1>Create report</h1>
            <p>logged in as <span th:text="${username}"></span></p>
            <h2 th:text="${fooData.getReportDate()}"></h2>
            <a href="#">choose report date...</a>
            <table class="table table-hover" id="my-table">
                <thead>
                    <tr><th>#</th><td class="hide"></td><th>Item name</th><th style="width:130px;text-align:center;">Today progress</th><th style="width:130px;text-align:center;">Total progress</th><th style="width:100px;text-align:center;">Actual time</th><th>Comment</th><th>Edit</th><th>Remove</th></tr>
                </thead>
                <tbody>
                    <tr th:each="item, iterStat : ${fooData.getEntries()}">
                        <td data-header="no" th:text="${iterStat.count}"></td>
                        <td class="hide" data-header="task.id" th:text="${item.getTask().getId()}"></td>
                        <td data-header="task.name" th:text="${item.getTask().getName()}"></td>
                        <td class="text-right"><span data-header="today_progress" th:text="${item.getTodayProgress()}"></span>%</td>
                        <td class="text-right"><span data-header="task.total_progress" th:text="${item.getTask().getTotalProgress()}"></span>%</td>
                        <td class="text-right"><span data-header="actual_time" th:text="${item.getActualTime()}"></span>h</td>
                        <td data-header="comment" th:text="${item.getComment()}"></td>
                        <td><span class="glyphicon glyphicon-pencil edit-item" style="color:#337ab7;"></span></td>
                        <td><span class="glyphicon glyphicon-remove remove-item" style="color:#d9534f;"></span></td>
                    </tr>
                </tbody>
            </table>
            <input type="button" class="btn btn-default" value="Add Item" id="add-item-modal-open">
        </div>
        <div id="add-item-modal" class="my-modal">
            <div id="modal-content">
                <form id='add-item-form'>
                    <h2><span id="add-item-form-title">Add Item</span></h2>
                    <table class="table">
                        <tr>
                            <th>
                                Today's Task number
                            </th>
                            <td data-header='no'>

                            </td>
                        </tr>
                        <tr>
                            <th>Task id</th>
                            <td data-header="task.id"></td>
                        </tr>
                        <tr>
                            <th>Item name</th>
                            <td><select data-header="task.id" id="task-select">
                                    <option value>---</option>
                                    <option th:each="task : ${tasks}" th:value="${task.getId()}" th:text="${task.getName()}">

                                    </option>
                                </select>
                            </td>
                        </tr>
                        <tr class="hide"><th></th><td data-header="task.name"></td></tr>
                        <tr>
                            <th>Scheduled start date</th>
                            <td data-header="task.scheduled_start_date">
                            </td>
                        </tr>
                        <tr>
                            <th>Scheduled end date</th>
                            <td data-header="task.scheduled_end_date">
                            </td>
                        </tr>
                        <tr>
                            <th>Actual start date</th>
                            <td data-header="task.actual_start_date">
                            </td>
                        </tr>
                        <tr>
                            <th>Actual end date</th>
                            <td data-header="task.actual_end_date">
                            </td>
                        </tr>
                        <tr>
                            <th>Today Progress</th>
                            <td><input type="number" data-header="today_progress" min="0" max="100" step="1" style="width:70px;"> %
                            </td>
                        </tr>
                        <tr>
                            <th>Total Progress</th>
                            <td><span data-header="task.total_progress"></span>%
                            </td>
                        </tr>
                        <tr>
                            <th>Actual time</th>
                            <td><input type="number" data-header="actual_time" min="0.25" max="24" step="0.25" style="width:70px;"> h
                            </td>
                        </tr>
                        <tr>
                            <th>Comment</th>
                            <td><textarea data-header="comment" rows="3"></textarea>
                            </td>
                        </tr>
                        <tr>
                            <td colspan="2">
                                <input type="button" value="Save" id='save-item' class="btn btn-default">
                                <input type="button" value="Close" id='add-item-modal-close' class="btn btn-default">
                            </td>
                        </tr>
                    </table>
                </form>
            </div>
        </div>
        <script>
            var trTemplate = '<td data-header="no"></td><td class="hide" data-header="task.id"></td><td data-header="task.name"></td><td class="text-right"><span data-header="today_progress"></span>%</td><td class="text-right"><span data-header="task.total_progress"></span>%</td><td class="text-right"><span data-header="actual_time"></span>h</td><td data-header="comment"></td><td><span class="glyphicon glyphicon-pencil edit-item" style="color:#337ab7;"></span></td><td><span class="glyphicon glyphicon-remove remove-item" style="color:#d9534f;"></span></td>'

            new Listener("onclick", byid("add-item-modal-open"))
                    .document(
                            text(byid('add-item-form-title'), 'Add Item'),
                            removeAttr(byid('task-select'), 'disabled'))
                    .update({'header': {
                            'task': {
                                'total_progress': '0'
                            },
                            'today_progress': '0',
                            'actual_time': '0'}})
                    .to(exchangeToElement(byid('add-item-form')))
                    .to(modal(byid('add-item-modal'), 'open'));

            new Listener('onclick', selectAll('#add-item-modal, #add-item-modal-close'))
                    .filter(_in(get(element(), 'id'), ['add-item-modal', 'add-item-modal-close']))
                    .to(modal(byid('add-item-modal'), 'close'));

            new Listener('onclick', '.edit-item')
                    .document(text(byid('add-item-form-title'), 'Edit Item'))
                    .to(loadElement(parent(element(), 2))) // TBD: elementToElement
                    .to(exchangeToElement(byid('add-item-form')))
                    .to(modal(byid('add-item-modal'), 'open'))
                    .document(attr(byid('task-select'), 'disabled', 'disabled'))
                    .task(server('/task-info'))
                    .to(log())
                    .to(exchangeToElement(byid('add-item-form')));

            new Listener('onclick', byid('save-item'))
                    .to(loadElement(byid('add-item-form')))
                    .filter(function (exchange) {
                        if (!exchange.getHeader("task.id")) {
                            window.alert("Please set Item name.");
                            return false;
                        }
                        return true;
                    })
                    .filter(all(query('#my-table tbody tr'),
                            or(eq(header('no'), text(query(element(), '[data-header="no"]'))),
                                    notEq(header('task.name'), text(query(element(), '[data-header="task.name"]')))),
                            _alert("That item has already been entered.")))
                    .to(function (exchange) {
                        var no = exchange.getHeader("no");
                        if (no) {
                            selectAll('#my-table tbody tr').forEach(function (element) {
                                if (element.querySelector('[data-header="no"]').innerHTML === no + "") {
                                    exchange.setElement(element);
                                }
                            });
                        } else {
                            var newNo = 0;
                            selectAll('#my-table tbody tr').forEach(function (element) {
                                newNo = Math.max(new Number(element.querySelector('[data-header="no"]').innerHTML), newNo);
                            });<commit_msg>fix report view logic<commit_after><!DOCTYPE html>

<html xmlns:th="http://www.thymeleaf.org" th:replace="~{fragments/layout :: layout (~{::body},'hello')}">
    <body>
        <div class="container">
            <h1>Create report</h1>
            <p>logged in as <span th:text="${username}"></span></p>
            <h2 th:text="${fooData.getReportDate()}"></h2>
            <a href="#">choose report date...</a>
            <table class="table table-hover" id="my-table">
                <thead>
                    <tr><th>#</th><td class="hide"></td><th>Item name</th><th style="width:130px;text-align:center;">Today progress</th><th style="width:130px;text-align:center;">Total progress</th><th style="width:100px;text-align:center;">Actual time</th><th>Comment</th><th>Edit</th><th>Remove</th></tr>
                </thead>
                <tbody>
                    <tr th:each="item, iterStat : ${fooData.getEntries()}">
                        <td data-header="no" th:text="${iterStat.count}"></td>
                        <td class="hide" data-header="task.id" th:text="${item.getTask().getId()}"></td>
                        <td data-header="task.name" th:text="${item.getTask().getName()}"></td>
                        <td class="text-right"><span data-header="today_progress" th:text="${item.getTodayProgress()}"></span>%</td>
                        <td class="text-right"><span data-header="task.total_progress" th:text="${item.getTask().getTotalProgress()}"></span>%</td>
                        <td class="text-right"><span data-header="actual_time" th:text="${item.getActualTime()}"></span>h</td>
                        <td data-header="comment" th:text="${item.getComment()}"></td>
                        <td><span class="glyphicon glyphicon-pencil edit-item" style="color:#337ab7;"></span></td>
                        <td><span class="glyphicon glyphicon-remove remove-item" style="color:#d9534f;"></span></td>
                    </tr>
                </tbody>
            </table>
            <input type="button" class="btn btn-default" value="Add Item" id="add-item-modal-open">
        </div>
        <div id="add-item-modal" class="my-modal">
            <div id="modal-content">
                <form id='add-item-form'>
                    <h2><span id="add-item-form-title">Add Item</span></h2>
                    <table class="table">
                        <tr>
                            <th>
                                Today's Task number
                            </th>
                            <td data-header='no'>

                            </td>
                        </tr>
                        <tr>
                            <th>Task id</th>
                            <td data-header="task.id"></td>
                        </tr>
                        <tr>
                            <th>Item name</th>
                            <td><select data-header="task.id" id="task-select">
                                    <option value>---</option>
                                    <option th:each="task : ${tasks}" th:value="${task.getId()}" th:text="${task.getName()}">

                                    </option>
                                </select>
                            </td>
                        </tr>
                        <tr class="hide"><th></th><td data-header="task.name"></td></tr>
                        <tr>
                            <th>Scheduled start date</th>
                            <td data-header="task.scheduled_start_date">
                            </td>
                        </tr>
                        <tr>
                            <th>Scheduled end date</th>
                            <td data-header="task.scheduled_end_date">
                            </td>
                        </tr>
                        <tr>
                            <th>Actual start date</th>
                            <td data-header="task.actual_start_date">
                            </td>
                        </tr>
                        <tr>
                            <th>Actual end date</th>
                            <td data-header="task.actual_end_date">
                            </td>
                        </tr>
                        <tr>
                            <th>Today Progress</th>
                            <td><input type="number" data-header="today_progress" min="0" max="100" step="1" style="width:70px;"> %
                            </td>
                        </tr>
                        <tr>
                            <th>Total Progress</th>
                            <td><span data-header="task.total_progress"></span>%
                            </td>
                        </tr>
                        <tr>
                            <th>Actual time</th>
                            <td><input type="number" data-header="actual_time" min="0.25" max="24" step="0.25" style="width:70px;"> h
                            </td>
                        </tr>
                        <tr>
                            <th>Comment</th>
                            <td><textarea data-header="comment" rows="3"></textarea>
                            </td>
                        </tr>
                        <tr>
                            <td colspan="2">
                                <input type="button" value="Save" id='save-item' class="btn btn-default">
                                <input type="button" value="Close" id='add-item-modal-close' class="btn btn-default">
                            </td>
                        </tr>
                    </table>
                </form>
            </div>
        </div>
        <script>
            var trTemplate = '<td data-header="no"></td><td class="hide" data-header="task.id"></td><td data-header="task.name"></td><td class="text-right"><span data-header="today_progress"></span>%</td><td class="text-right"><span data-header="task.total_progress"></span>%</td><td class="text-right"><span data-header="actual_time"></span>h</td><td data-header="comment"></td><td><span class="glyphicon glyphicon-pencil edit-item" style="color:#337ab7;"></span></td><td><span class="glyphicon glyphicon-remove remove-item" style="color:#d9534f;"></span></td>'

            new Listener("onclick", byid("add-item-modal-open"))
                    .document(
                            text(byid('add-item-form-title'), 'Add Item'),
                            removeAttr(byid('task-select'), 'disabled'))
                    .update({'header': {
                            'task': {
                                'total_progress': '0'
                            },
                            'today_progress': '0',
                            'actual_time': '0'}})
                    .to(exchangeToElement(byid('add-item-form')))
                    .to(modal(byid('add-item-modal'), 'open'));

            new Listener('onclick', selectAll('#add-item-modal, #add-item-modal-close'))
                    .filter(_in(get(element(), 'id'), ['add-item-modal', 'add-item-modal-close']))
                    .to(modal(byid('add-item-modal'), 'close'));

            new Listener('onclick', '.edit-item')
                    .document(text(byid('add-item-form-title'), 'Edit Item'))
                    .to(loadElement(parent(element(), 2))) // TBD: elementToElement
                    .to(exchangeToElement(byid('add-item-form')))
                    .to(modal(byid('add-item-modal'), 'open'))
                    .document(attr(byid('task-select'), 'disabled', 'disabled'))
                    .task(server('/task-info'))
                    .to(log())
                    .to(exchangeToElement(byid('add-item-form')));

            new Listener('onclick', byid('save-item'))
                    .to(loadElement(byid('add-item-form')))
                    .filter(function (exchange) {
                        if (!exchange.getHeader("task.id")) {
                            window.alert("Please set Item name.");
                            return false;
                        }
                        return true;
                    })
                    .filter(all(query('#my-table tbody tr'),
                            or(eq(header('no'), text(query(element(), '[data-header="no"]'))),
                                    notEq(header('task.id'), text(query(element(), '[data-header="task.id"]')))),
                            _alert("That item has already been entered.")))
                    .to(function (exchange) {
                        var no = exchange.getHeader("no");
                        if (no) {
                            selectAll('#my-table tbody tr').forEach(function (element) {
                                if (element.querySelector('[data-header="no"]').innerHTML === no + "") {
                                    exchange.setElement(element);
                                }
                            });
                        } else {
                            var newNo = 0;
                            selectAll('#my-table tbody tr').forEach(function (element) {
                                newNo = Math.max(new Number(element.querySelector('[data-header="no"]').innerHTML), newNo);
                            });
{'fraction_non_alphanumeric': 0.16202858063822928, 'fraction_numerical': 0.005909530460943376, 'mean_word_length': 1.1716052263182455, 'pattern_counts': {'":': 0, '<': 409, '<?xml version=': 0, '>': 409, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5616154', 'n_tokens_mistral': 4922, 'n_tokens_neox': 4649, 'n_words': 721}