Subversion Repositories wpShopGermany4

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
7957 daniel 1
<?php
2
 
3
	declare(strict_types=1);
4
 
5
	/**
6
	 * User: Daschmi (daschmi@daschmi.de)
7
	 * Date: 04.11.2021
8
	 * Time: 10:28
9
	 */
10
 
11
?>
12
 
13
<script src="<?php echo WPSG_URL_CONTENT.'plugins/'.WPSG_FOLDERNAME.'/views/js/vue3.js'; ?>"></script>
14
 
15
<div id="wpsg_mod_orderstates_app">
16
 
17
    <textarea name="wpsg_mod_orderstates[states]" class="none">{{arStates}}</textarea>
18
 
19
    <p class="flex items-center justify-between">
20
        <template v-if="arStatesNotDeleted.length === 0">
21
            <?php echo __('Keine Bestellzustände angelegt.', 'wpsg'); ?>
22
        </template>
23
        <template v-if="arStatesNotDeleted.length === 1">
24
            <?php echo __('Ein Bestellzustand wurde definiert.', 'wpsg'); ?>
25
        </template>
26
        <template v-else>
27
            {{arStatesNotDeleted.length}} <?php echo __('Bestellzustände wurden definiert.', 'wpsg'); ?>
28
        </template>
29
        <a href="#" @click.prevent="add()">
30
            <span class="wpsg-glyphicon glyphicon glyphicon-plus"></span><?php echo __('Neuen Bestellzustand anlegen', 'wpsg'); ?>
31
        </a>
32
    </p>
33
 
34
    <table class="w-full mt-2">
35
        <tbody v-for="(row, i) of arStatesNotDeleted">
36
            <tr>
37
                <td class="p-1 w-full">
38
                    <input class="w-full box-border" type="text" v-model="row.name" />
39
                </td>
40
                <td class="p-1 text-right">
41
 
42
                    <a href="#" @click.prevent="deleteRow(row)" title="<?php echo __('Bestellzustand löschen', 'wpsg'); ?>">
43
                        <span class="glyphicon glyphicon-trash"></span>
44
                    </a>
45
 
46
                </td>
47
            </tr>
48
        </tbody>
49
    </table>
50
 
51
</div>
52
 
53
<script>
54
 
55
    const Counter = {
56
        data() {
57
            return {
58
                arStates: <?php echo json_encode($this->view['arStates']); ?>
59
            }
60
        },
61
        computed: {
62
			arStatesNotDeleted() {
63
 
64
				let r = [];
65
 
66
				for (let s of this.arStates) if (s.deleted !== '1') r.push(s);
67
 
68
				return r;
69
 
70
            }
71
        },
72
        methods: {
73
			add() {
74
 
75
				this.arStates.push({
76
                    id: 0,
77
                    name: '',
78
                    deleted: 0
79
				});
80
 
81
            },
82
            deleteRow(row) {
83
 
84
				row.deleted = '1';
85
 
86
            }
87
        }
88
    }
89
 
90
    Vue.createApp(Counter).mount('#wpsg_mod_orderstates_app')
91
 
92
</script>