Skip to content

Commit 73bc0de

Browse files
committed
Modified address modal and xtenspg query to retrieve owner info #38
1 parent dd8676d commit 73bc0de

File tree

2 files changed

+24
-19
lines changed

2 files changed

+24
-19
lines changed

assets/js/modules/XtensTable.js

+18-13
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
var Data = xtens.module("data");
3636
var Sample = xtens.module("sample");
3737
var DataFile = xtens.module("datafile");
38+
var AddressInformation = xtens.module("addressinformation");
3839
var VIEW_OVERVIEW = Privileges.VIEW_OVERVIEW;
3940
var ModalDialog = xtens.module("xtensbootstrap").Views.ModalDialog;
4041

@@ -167,21 +168,25 @@
167168
return pr.id === data.type;
168169
});
169170

171+
var address = new AddressInformation.Model({id: data.owner_address});
172+
var addressDeferred = address.fetch();
170173

171-
if (that.modal) {
172-
that.modal.hide();
173-
}
174-
var modal = new ModalDialog({
175-
template: JST["views/templates/address-modal.ejs"],
176-
data: { __: i18n, project: project[0], data: data}
177-
});
174+
$.when(addressDeferred).then(function(addressRes) {
175+
if (that.modal) {
176+
that.modal.hide();
177+
}
178+
var modal = new ModalDialog({
179+
template: JST["views/templates/address-modal.ejs"],
180+
data: { __: i18n, project: project[0], data: data, address: addressRes}
181+
});
178182

179-
that.$modal.append(modal.render().el);
180-
modal.show();
183+
that.$modal.append(modal.render().el);
184+
modal.show();
181185

182-
that.$('.query-modal').on('hidden.bs.modal', function (e) {
183-
modal.remove();
184-
$('.modal-backdrop').remove();
186+
that.$('.query-modal').on('hidden.bs.modal', function (e) {
187+
modal.remove();
188+
$('.modal-backdrop').remove();
189+
});
185190
});
186191

187192
} );
@@ -219,7 +224,7 @@
219224
}
220225
var flattenedFields = this.dataType.getFlattenedFields(); // get the names of all the madatafields but those within loops;
221226
this.columns = this.insertModelSpecificColumns(this.dataType.get("model"), xtens.session.get('canAccessPersonalData'));
222-
this.columns.push({"title": i18n("owner"), "data": "owner.lastName", "className": "owner"});
227+
this.columns.push({"title": i18n("owner"), "data": "owner_surname", "className": "owner"});
223228

224229
this.numLeft=this.columns.length;
225230

views/templates/address-modal.ejs

+6-6
Original file line numberDiff line numberDiff line change
@@ -16,31 +16,31 @@
1616
<div class="form-group metadataform-group">
1717
<label for="firstName" class="data-label"><%= __('given-name') %></label>
1818
<div class="data-input-div">
19-
<span class="form-control" id="firstName" placeholder="Name" name="firstName" ><%= data.owner.lastName %></span>
19+
<span class="form-control" id="firstName" placeholder="Name" name="firstName" ><%= data.owner_surname %></span>
2020
</div>
2121
</div>
2222
<div class="form-group metadataform-group">
2323
<label for="lastName" class="data-label"><%= __('surname') %></label>
2424
<div class="data-input-div">
25-
<span class="form-control" id="lastName" placeholder="Surname" name="lastName" ><%= data.owner.firstName %></span>
25+
<span class="form-control" id="lastName" placeholder="Surname" name="lastName" ><%= data.owner_name %></span>
2626
</div>
2727
</div>
2828
<div class="form-group metadataform-group">
29-
<label for="birthDate" class="data-label"><%= __('laboratory') %></label>
29+
<label for="birthDate" class="data-label"><%= __('office') %></label>
3030
<div class="data-input-div">
31-
<span class="form-control" id="birthDate" name="birthDate" placeholder="<%= __('please-select') %>" ><%= data.owner.laboratory %></span>
31+
<span class="form-control" id="birthDate" name="birthDate" placeholder="<%= __('please-select') %>" ><%= address.office %></span>
3232
</div>
3333
</div>
3434
<div class="form-group metadataform-group">
3535
<label for="email" class="data-label"><%= __('email') %></label>
3636
<div class="data-input-div">
37-
<span name="email" type="email" class="form-control" id="email" placeholder="ex@example.com"><%= data.owner.email %></span>
37+
<span name="email" type="email" class="form-control" id="email" placeholder="ex@example.com"><%= data.owner_email %></span>
3838
</div>
3939
</div>
4040
<div class="form-group metadataform-group">
4141
<label for="login" class="data-label"><%= __('phone') %></label>
4242
<div class="data-input-div">
43-
<span class="form-control" id="login" name="login" placeholder="Username" ><%= data.owner.phone %></span>
43+
<span class="form-control" id="login" name="login" placeholder="Username" ><%= address.phone %></span>
4444
</div>
4545
</div>
4646
</div>

0 commit comments

Comments
 (0)