Projet

Général

Profil

0001-admin-add-handles-to-sortable-items-11015.patch

Frédéric Péters, 20 mai 2016 20:03

Télécharger (7,75 ko)

Voir les différences:

Subject: [PATCH] admin: add handles to sortable items (#11015)

 tests/test_admin_pages.py           |  8 ++++----
 wcs/admin/fields.py                 |  4 +++-
 wcs/admin/workflows.py              | 14 +++++++------
 wcs/qommon/static/css/dc2/admin.css | 40 ++++++++++++++++++++++++++++++++++++-
 wcs/qommon/static/js/biglist.js     |  4 ++++
 5 files changed, 58 insertions(+), 12 deletions(-)
tests/test_admin_pages.py
766 766
    assert resp.location == 'http://example.net/backoffice/forms/1/fields/'
767 767
    resp = resp.follow()
768 768
    assert 'foobar' in resp.body
769
    assert 'Use drag and drop to reorder fields.' in resp.body
769
    assert 'Use drag and drop' in resp.body
770 770

  
771 771
    assert len(FormDef.get(1).fields) == 1
772 772
    assert FormDef.get(1).fields[0].key == 'string'
......
796 796
    resp = app.get('/backoffice/forms/1/')
797 797
    resp = resp.click(href='fields/')
798 798
    assert '1st field' in resp.body
799
    assert 'Use drag and drop to reorder fields.' in resp.body
799
    assert 'Use drag and drop' in resp.body
800 800

  
801 801
    resp = resp.click(href='1/delete')
802 802
    resp = resp.forms[0].submit()
......
960 960
    assert resp.location == 'http://example.net/backoffice/forms/1/fields/'
961 961
    resp = resp.follow()
962 962
    assert 'foobar' in resp.body
963
    assert 'Use drag and drop to reorder fields.' in resp.body
963
    assert 'Use drag and drop' in resp.body
964 964

  
965 965
    assert len(FormDef.get(1).fields) == 1
966 966
    assert FormDef.get(1).fields[0].key == 'page'
......
1306 1306
    resp = resp.forms[0].submit()
1307 1307
    assert resp.location == 'http://example.net/backoffice/workflows/1/status/1/'
1308 1308
    resp = resp.follow()
1309
    assert 'Use drag and drop to reorder items' in resp.body
1309
    assert 'Use drag and drop' in resp.body
1310 1310

  
1311 1311
    # fill action
1312 1312
    resp = resp.click('Display message')
wcs/admin/fields.py
1
# -*- coding: utf-8 -*-
2
#
1 3
# w.c.s. - web application for online forms
2 4
# Copyright (C) 2005-2010  Entr'ouvert
3 5
#
......
201 203
                    r += htmltext(_('In a multipage form, the first field should be of type "page".'))
202 204
                    r += htmltext('</div>')
203 205

  
204
            r += htmltext('<p>%s</p>') % _('Use drag and drop to reorder fields.')
206
            r += htmltext('<p class="hint">%s</p>') % _('Use drag and drop with the ⠿ handles to reorder items.')
205 207
            if self.page_no is not None:
206 208
                r += htmltext('<p>')
207 209
                r += htmltext('<a href="../../">%s</a>') % _('Display all pages')
wcs/admin/workflows.py
1
# -*- coding: utf-8 -*-
2
#
1 3
# w.c.s. - web application for online forms
2 4
# Copyright (C) 2005-2010  Entr'ouvert
3 5
#
......
422 424
            if str(self.workflow.id).startswith(str('_')):
423 425
                r += htmltext('<ul id="items-list" class="biglist">')
424 426
            else:
425
                r += htmltext('<p>')
426
                r += _('Use drag and drop to reorder items.')
427
                r += htmltext('<p class="hint">')
428
                r += _('Use drag and drop with the ⠿ handles to reorder items.')
427 429
                r += htmltext('</p>')
428 430
                r += htmltext('<ul id="items-list" class="biglist sortable">')
429 431
            for i, item in enumerate(self.status.items):
......
1077 1079
            if str(self.workflow.id).startswith('_'):
1078 1080
                r += htmltext('<ul id="items-list" class="biglist">')
1079 1081
            else:
1080
                r += htmltext('<p>')
1081
                r += _('Use drag and drop to reorder items.')
1082
                r += htmltext('<p class="items">')
1083
                r += _('Use drag and drop with the ⠿ handles to reorder items.')
1082 1084
                r += htmltext('</p>')
1083 1085
                r += htmltext('<ul id="items-list" class="biglist sortable">')
1084 1086
            for i, item in enumerate(self.action.items):
......
1323 1325
            r += htmltext('<p>%s</p>') % _('There are not yet any status defined in this workflow.')
1324 1326
        else:
1325 1327
            if not str(self.workflow.id).startswith(str('_')):
1326
                r += htmltext('<p>')
1327
                r += _('Use drag and drop to reorder status.')
1328
                r += htmltext('<p class="hint">')
1329
                r += _('Use drag and drop with the ⠿ handles to reorder status.')
1328 1330
                r += htmltext('</p>')
1329 1331
                r += htmltext('<ul id="status-list" class="biglist sortable">')
1330 1332
            else:
wcs/qommon/static/css/dc2/admin.css
21 21
	padding: 0.5em 0;
22 22
}
23 23

  
24
ul.biglist span.handle {
25
	cursor: grab;
26
	display: inline-block;
27
	padding: 0.5ex;
28
	text-align: center;
29
	width: 1em;
30
}
31

  
24 32
ul.biglist li,
25 33
li.biglistitem {
26 34
	list-style-type: none;
......
35 43
	line-height: 2.5em;
36 44
}
37 45

  
46
ul.biglist.sortable li {
47
	padding-left: 0;
48
}
49

  
38 50
ul.biglist li.smallitem {
39 51
	font-size: 80%;
40 52
	background: #fffff4;
......
62 74
	padding-right: 5px;
63 75
}
64 76

  
77
p.hint {
78
	color: #aaa;
79
}
80

  
81
div.bo-block p.hint {
82
	color: inherit;
83
}
84

  
85
p.hint::before {
86
	content: "\f05a";
87
	font-family: FontAwesome;
88
	padding-right: 1ex;
89
}
90

  
65 91
td.time {
66 92
	text-align: right;
67 93
}
......
612 638
	border-width: 1px 0 0 0;
613 639
	border-color: #e4e4e4;
614 640
	padding: 0;
641
	transition: background 0.25s ease 0s;
615 642
}
616 643

  
617 644
div.bo-block ul.biglist h3 {
......
635 662
	color: #888;
636 663
}
637 664

  
665
div.bo-block ul.biglist.sortable li strong a,
666
div.bo-block ul.biglist.sortable li > a,
667
ul.biglist.sortable a {
668
	display: inline-block;
669
	width: calc(100% - 1em - 3ex);
670
}
671

  
638 672
div.bo-block ul.biglist li > a,
639 673
div.bo-block ul.biglist strong a {
640 674
	display: block;
......
642 676
	border: none;
643 677
	font-weight: normal;
644 678
	color: #215D9C;
645
	transition: all 0.25s ease 0s;
646 679
}
647 680

  
648 681
div.bo-block ul.biglist strong a.fake {
......
666 699
	color: white;
667 700
}
668 701

  
702
div.bo-block ul.biglist.sortable li:hover,
669 703
div.bo-block ul.biglist a:hover {
670 704
	background: #ccc;
671 705
}
672 706

  
707
div.bo-block ul.biglist.sortable li:hover a:hover {
708
	background: transparent;
709
}
710

  
673 711
div.bo-block span.disabled a {
674 712
	color: #666;
675 713
	text-decoration: none;
wcs/qommon/static/js/biglist.js
5 5
             * set with position: relative and overflow properties */
6 6
            $('#main-content').css('overflow', 'inherit');
7 7
        }
8
        $('ul.biglist.sortable li').each(function(i, elem) {
9
            $('<span class="handle">⠿</span>').prependTo(elem);
10
        });
8 11
        $('ul.biglist.sortable').sortable(
9 12
            {
13
                handle: '.handle',
10 14
                accept: 'biglistitem',
11 15
                scroll: true,
12 16
                helper: 'clone',
13
-