aboutsummaryrefslogtreecommitdiffstats
path: root/jm2l/templates/edit_tiers.mako
blob: 5b7a49c5dbe6f92f5de8cbbf6b916a551f43c797 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
<%inherit file="jm2l:templates/layout.mako"/>
<%namespace name="helpers" file="jm2l:templates/helpers.mako"/>
<%def name="cssAddOn()">    
  <link rel="stylesheet" href="/vendor/select2/css/select2.css" type="text/css" media="screen" />
  <link rel="stylesheet" href="/vendor/fileupload/css/jquery.fileupload.css">
  <link rel="stylesheet" href="/vendor/fileupload/css/jquery.fileupload-ui.css">
  <!-- CSS adjustments for browsers with JavaScript disabled -->
  <noscript><link rel="stylesheet" href="/vendor/fileupload/css/jquery.fileupload-noscript.css"></noscript>
  <noscript><link rel="stylesheet" href="/vendor/fileupload/css/jquery.fileupload-ui-noscript.css"></noscript>
</%def>
<a class="pull-right" href="/categorie/entity">Editer les catégories</a>
<br>
<form action="" method="POST">
        % if 'uid' in form._fields:
            ${form.uid}
        %endif
<%
DicForm = {
    'name':        {'PlaceHolder':u"Nom",         'ContainerStyle':"padding-right:5px;float:left;width:35em;", "FieldStyle":"width:31em;"},
    'tiers_type':  {'PlaceHolder':u"Nature",      'ContainerStyle':"padding-right:5px;", "FieldStyle":"width:15em;"},
    'description': {'PlaceHolder':u"Description", 'ContainerStyle':"padding-right:5px;padding-top: 20px;", "FieldStyle":"width:90%;min-height:150px;" },
    'website':     {'PlaceHolder':u"Site web",    'ContainerStyle':"padding-right:15px;", 'ContainerStyle':"width:30em;"},
    'membership':  {'Ignore':True}
    } 
%>

    ${helpers.DisplayForm(form, DicForm)}

% if 'uid' in form._fields:
<fieldset>
    <legend>Acteurs</legend>
<div class="repeat">
    <table class="wrapper" width="100%">
        <thead>
          <tr class="row">
            <th style="width:5em;text-align:center;">Année</th>
            <th>Personne</th>
            <th style="width:22em;">Rôle</th>
            <th style="width:5em;">Action</th>            
          </tr>            
        </thead>
        <tbody class="container">
        <tr class="row template" style="line-height:2.2em;">
            <td><span class="move btn btn-mini btn-info">Move</span></td>
            <td>
                <select class="form-control" style="width:5em;" name="membership-{{row-count-placeholder}}-year_uid"
                    id="membership-{{row-count-placeholder}}-year_uid">
                    % for year in range(2015, 2005, -1):
                        <% 
                        if year in [2014]:
                            continue
                        %> \
                        <option value="${year}">${year}</option>
                    %endfor
                </select>
            </td>
            <td style="text-align: center;">
                <input type="hidden" style="width:20em;" class="form-control" name="membership-{{row-count-placeholder}}-user_uid" 
                    id="membership-{{row-count-placeholder}}-user_uid" />
            </td>
            <td style="text-align: center;">                    
                <select class="form-control" style="width:20em;" name="membership-{{row-count-placeholder}}-role"
                    id="membership-{{row-count-placeholder}}-role">
                    % for opt in UserOptions:
                        <option value="${opt.uid}">${opt.exch_subtype}</option>
                    % endfor
                </select>
            </td>
            <td>
                <span class="remove btn btn-mini btn-danger">
                    <i class="icon-remove-sign icon-white"></i> Suppr.
                </span>
            </td>            
        </tr>
        % for num, dicdata in enumerate(form._fields.get("membership").data):
        <tr class="row" style="padding:5px;line-height:2.2em;">
            <td><span class="move btn btn-mini btn-info">Move</span></td>
            <td style="text-align:center;">
                <input type="hidden" class="form-control" name="membership-${num}-year_uid" 
                    value="${dicdata.get('year_uid')}" style="width:4em;" />
                ${dicdata.get('year_uid')}
            </td>
            <td style="text-align:center;">                
                <input type="hidden" class="form-control" name="membership-${num}-user_uid" 
                    value="${dicdata.get('user_uid')}" style="width:4em;" />
                <% 
                tmpUser = DBUser.by_id(dicdata.get('user_uid'))
                %>
                % if tmpUser:
                ${tmpUser.prenom} ${tmpUser.nom}
                % endif
            </td>
            <td style="text-align:center;">
                <input type="hidden" class="form-control" name="membership-${num}-role" 
                    value="${dicdata.get('role')}" />
                <i>${dicdata.get('role', 'Aucun')}</i>
            </td>
            <td>
                <span class="remove btn btn-mini btn-danger">
                    <i class="icon-remove-sign icon-white"></i> Suppr.
                </span>
            </td>
        </tr>
        % endfor
        </tbody>
        <tfoot>
          <tr>
            <td colspan="5" style="text-align:center;line-height: 3em;">
                <span class="add btn btn-mini btn-primary"><i class="icon-plus-sign icon-white"></i> Ajouter</span>
            </td>
          </tr>            
        </tfoot>
    </table>
</div>
</fieldset>
% endif
% if 'uid' in form._fields:
    <button type="submit">Enregistrer</button>
% else:
    <button type="submit">Proposer</button>
% endif
</form>
    % if 'uid' in form._fields:
        % if request.user:
<fieldset>
    <legend>Support liés</legend>
        <div style="float:right;width:60%">
            <p> En plus de vos support de présentation classique.
            Pensez aussi aux affiches, aux flyers, aux stickers,
            au bulletin d'adhésion à une association, à la documentation technique...
            Tous ce qui peut être utile, de près ou de loin à la promotion de votre évenement.
            </p>
        </div>
        ${helpers.uploader("tiers", form.uid.data, u"fichiers" )}
</fieldset>
        % else:
        <br>NB: Vous devez être identifié afin de proposer du contenu.
        % endif
    % else:
        <br>NB: Vous devez proposer votre entité avant de pouvoir
        téléverser des fichiers la concernant.
    % endif
<br>
<br>
<br>

% if 'uid' in form._fields:
    ${helpers.uploader_js()}
% endif

<%def name="jsAddOn()">
    <script src="/vendor/select2/js/select2.js"></script>
    <script src="/vendor/repeatable-fields/js/repeatable-fields.js"></script>
    <script src="/vendor/ckeditor/ckeditor.js"></script>    
<script type="text/javascript">
var year_data = Array();
var editor = CKEDITOR.replace('description', { autoGrow_onStartup: true, language: 'fr' } );
for (var i=2005;i<2015;i++)
    { year_data[i.toString()] = i.toString(); };

$("#tiers_type").select2({});

function show_editor() {
    if (editor) {
        editor.destroy();
        editor=null;
    } else
        editor = CKEDITOR.replace('description');
}

jQuery(function() {
    jQuery('.repeat').each(function() {
        jQuery(this).repeatable_fields(
            {
            is_ready: function(container, therow) {
                var numrow=$(container).attr('data-rf-row-count');
                $("#membership-"+ (numrow-1) +"-user_uid").select2(
                    {
                        placeholder: 'Entrez ici un Nom ou un Prénom',
                        minimumInputLength: 2, allowClear: true,
                        ajax: {
                            quietMillis: 250, url: "/json-users", dataType: 'json',
                            data: function (term, page) {
                                return { pageSize: 8, pageNum: page, searchTerm: term };
                            },
                            results: function (data, page) {
                                var more = (page * 8) < data.Total; 
                                return { results: data.Results, more: more };
                            }
                        }
                    });
                $("#membership-"+ (numrow-1) +"-year_uid").select2({});
                $("#membership-"+ (numrow-1) +"-role").select2({});
            }
        });
    });
});
</script>
</%def>