Skip to content

Commit 56fef02

Browse files
authored
Merge pull request #941 from crazyserver/MOBILE-1987
Mobile 1987
2 parents 957c1a7 + 824e5f2 commit 56fef02

File tree

11 files changed

+118
-56
lines changed

11 files changed

+118
-56
lines changed

www/addons/mod/assign/controllers/edit.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,7 @@ angular.module('mm.addons.mod_assign')
9898
});
9999
});
100100
}).catch(function(message) {
101-
if (message) {
102-
$mmUtil.showErrorModal(message);
103-
} else {
104-
$mmUtil.showErrorModal('Error getting assigment data.');
105-
}
101+
$mmUtil.showErrorModalDefault(message, 'Error getting assigment data.');
106102
blockData && blockData.back();
107103
return $q.reject();
108104
});

www/addons/mod/choice/templates/index.html

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,6 @@
5555
<div class="item item-divider">
5656
<h3>{{ 'mma.mod_choice.responses' | translate }}</h3>
5757
</div>
58-
<div class="mm-warning" ng-if="hasOffline">
59-
<i class="icon ion-alert-circled padding"></i> {{ 'mma.mod_choice.resultsnotsynced' | translate }}
60-
</div>
6158
<div class="row row-no-padding responsive-md">
6259
<div class="col col-33">
6360
<div class="mm-warning" ng-if="hasOffline">

www/addons/mod/forum/scss/styles.scss

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,12 @@
5353
border-left: 0;
5454
border-right: 0;
5555
}
56+
.item-media:first-child {
57+
border-top: 0;
58+
}
59+
.item-media:last-child {
60+
border-bottom: 0;
61+
}
5662
}
5763

5864
.item-divider {

www/addons/mod/glossary/controllers/edit.js

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -151,11 +151,15 @@ angular.module('mm.addons.mod_glossary')
151151
});
152152
}
153153
}).then(function(attach) {
154-
var cats = $scope.categories.filter(function(category) {
155-
return category.selected;
156-
}).map(function(category) {
157-
return category.id;
158-
});
154+
var cats = [];
155+
156+
if ($scope.categories) {
157+
cats = $scope.categories.filter(function(category) {
158+
return category.selected;
159+
}).map(function(category) {
160+
return category.id;
161+
});
162+
}
159163

160164
var options = {
161165
aliases: $scope.options.aliases || "",
@@ -174,11 +178,11 @@ angular.module('mm.addons.mod_glossary')
174178
var promise;
175179
if (entry && !allowDuplicateEntries) {
176180
// Check if the entry is duplicated in online or offline mode.
177-
promise = $mmaModGlossary.isConceptUsed(glossaryId, concept, entry.timecreated).then(function() {
178-
// There's a entry with same name, reject with error message.
179-
return $mmLang.translateAndReject('mma.mod_glossary.errconceptalreadyexists');
180-
}, function() {
181-
// Not found, entry can be sent.
181+
promise = $mmaModGlossary.isConceptUsed(glossaryId, concept, entry.timecreated).then(function(used) {
182+
if (used) {
183+
// There's a entry with same name, reject with error message.
184+
return $mmLang.translateAndReject('mma.mod_glossary.errconceptalreadyexists');
185+
}
182186
});
183187
} else {
184188
promise = $q.when();
@@ -187,14 +191,14 @@ angular.module('mm.addons.mod_glossary')
187191
return promise.then(function() {
188192
// Save entry in offline.
189193
return $mmaModGlossaryOffline.saveAddEntry(glossaryId, concept, definition, courseId, options, attach,
190-
undefined, undefined, entry).then(function() {
194+
timecreated, undefined, undefined, entry).then(function() {
191195
// Don't return anything.
192196
});
193197
});
194198
} else {
195199
// Try to send it to server.
196200
// Don't allow offline if there are attachments since they were uploaded fine.
197-
return $mmaModGlossary.addEntry(glossaryId, concept, definition, courseId, options, attach, undefined,
201+
return $mmaModGlossary.addEntry(glossaryId, concept, definition, courseId, options, attach, timecreated, undefined,
198202
entry, !attachments.length, !allowDuplicateEntries);
199203
}
200204
}).then(function(entryId) {

www/addons/mod/glossary/services/glossary.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -764,14 +764,15 @@ angular.module('mm.addons.mod_glossary')
764764
* @param {Number} courseId Course ID of the glossary.
765765
* @param {Array} [options] Array of options for the entry.
766766
* @param {Mixed} [attach] Attachments ID if sending online, result of $mmFileUploader#storeFilesToUpload otherwise.
767+
* @param {Number} [timecreated] The time the entry was created. If not defined, current time.
767768
* @param {String} [siteId] Site ID. If not defined, current site.
768769
* @param {Object} [discardEntry] The entry provided will be discarded if found.
769770
* @param {Boolean} allowOffline True if it can be stored in offline, false otherwise.
770771
* @param {Boolean} [checkDuplicates] Check for duplicates before storing offline. Only used if allowOffline is true.
771772
* @return {Promise} Promise resolved with entry ID if entry was created in server, false if stored in device.
772773
*/
773-
self.addEntry = function(glossaryId, concept, definition, courseId, options, attach, siteId, discardEntry, allowOffline,
774-
checkDuplicates) {
774+
self.addEntry = function(glossaryId, concept, definition, courseId, options, attach, timecreated, siteId, discardEntry,
775+
allowOffline, checkDuplicates) {
775776
siteId = siteId || $mmSite.getId();
776777

777778
if (!$mmApp.isOnline() && allowOffline) {
@@ -800,15 +801,15 @@ angular.module('mm.addons.mod_glossary')
800801

801802
// Convenience function to store a new entry to be synchronized later.
802803
function storeOffline() {
803-
var timecreated = discardEntry && discardEntry.timecreated,
804-
duplicatesPromise = checkDuplicates ? self.isConceptUsed(glossaryId, concept, timecreated, siteId) : $q.when(false);
804+
var discardTime = discardEntry && discardEntry.timecreated,
805+
duplicatesPromise = checkDuplicates ? self.isConceptUsed(glossaryId, concept, discardTime, siteId) : $q.when(false);
805806
// Check if the entry is duplicated in online or offline mode.
806807
return duplicatesPromise.then(function(used) {
807808
if (used) {
808809
return $mmLang.translateAndReject('mma.mod_glossary.errconceptalreadyexists');
809810
}
810811

811-
return $mmaModGlossaryOffline.saveAddEntry(glossaryId, concept, definition, courseId, options, attach,
812+
return $mmaModGlossaryOffline.saveAddEntry(glossaryId, concept, definition, courseId, options, attach, timecreated,
812813
siteId, undefined, discardEntry).then(function() {
813814
return false;
814815
});
@@ -909,7 +910,6 @@ angular.module('mm.addons.mod_glossary')
909910
return true;
910911
}
911912
}
912-
913913
return false;
914914
});
915915
}).catch(function() {

www/addons/mod/glossary/services/glossary_offline.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,12 +170,14 @@ angular.module('mm.addons.mod_glossary')
170170
* @param {Number} courseId Course ID of the glossary.
171171
* @param {Array} [options] Array of options for the entry.
172172
* @param {Object} [attach] Result of $mmFileUploader#storeFilesToUpload for attachments.
173+
* @param {Number} [timecreated] The time the entry was created. If not defined, current time.
173174
* @param {String} [siteId] Site ID. If not defined, current site.
174175
* @param {Number} [userId] User the entry belong to. If not defined, current user in site.
175176
* @param {Object} [discardEntry] The entry provided will be discarded if found.
176177
* @return {Promise} Promise resolved if stored, rejected if failure.
177178
*/
178-
self.saveAddEntry = function(glossaryId, concept, definition, courseId, options, attach, siteId, userId, discardEntry) {
179+
self.saveAddEntry = function(glossaryId, concept, definition, courseId, options, attach, timecreated, siteId, userId,
180+
discardEntry) {
179181
return $mmSitesManager.getSite(siteId).then(function(site) {
180182
userId = userId || site.getUserId();
181183

@@ -187,7 +189,7 @@ angular.module('mm.addons.mod_glossary')
187189
definitionformat: 'html',
188190
options: options,
189191
userid: userId,
190-
timecreated: new Date().getTime()
192+
timecreated: timecreated || new Date().getTime()
191193
};
192194

193195
if (attach) {

www/addons/mod/wiki/controllers/map.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,19 @@ angular.module('mm.addons.mod_wiki')
2929
letter = {};
3030

3131
$scope.map = [];
32+
subwikiPages = subwikiPages.sort(function(a, b) {
33+
var compareA = a.title.toLowerCase().trim(),
34+
compareB = b.title.toLowerCase().trim();
35+
36+
return compareA.localeCompare(compareB);
37+
});
3238

3339
angular.forEach(subwikiPages, function(page) {
40+
var letterCandidate = page.title.charAt(0).toLocaleUpperCase();
3441
// Should we create a new grouping?
35-
if (page.title.charAt(0).toLocaleUpperCase() !== initialLetter) {
36-
initialLetter = page.title.charAt(0).toLocaleUpperCase();
37-
letter = {label: initialLetter, pages: []};
42+
if (letterCandidate !== initialLetter) {
43+
initialLetter = letterCandidate;
44+
letter = {label: letterCandidate, pages: []};
3845

3946
$scope.map.push(letter);
4047
}

www/core/components/fileuploader/services/helper.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,10 @@ angular.module('mm.core.fileuploader')
8888
* @return {Promise} Promise resolved when the user confirms or if there's no need to show a modal.
8989
*/
9090
self.confirmUploadFile = function(size, alwaysConfirm, allowOffline, wifiThreshold, limitedThreshold) {
91+
if (size == 0) {
92+
return $q.when();
93+
}
94+
9195
if (!allowOffline && !$mmApp.isOnline()) {
9296
return $mmLang.translateAndReject('mm.fileuploader.errormustbeonlinetoupload');
9397
}

www/core/lib/util.js

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -664,10 +664,6 @@ angular.module('mm.core')
664664
* If not defined, modal won't be automatically closed.
665665
*/
666666
self.showErrorModal = function(errorMessage, needsTranslate, autocloseTime) {
667-
var errorKey = 'mm.core.error',
668-
langKeys = [errorKey],
669-
matches;
670-
671667
if (angular.isObject(errorMessage)) {
672668
// We received an object instead of a string. Search for common properties.
673669
if (typeof errorMessage.content != 'undefined') {
@@ -684,31 +680,33 @@ angular.module('mm.core')
684680
}
685681

686682
// Try to remove tokens from the contents.
687-
matches = errorMessage.match(/token"?[=|:]"?(\w*)/, '');
683+
var matches = errorMessage.match(/token"?[=|:]"?(\w*)/, '');
688684
if (matches && matches[1]) {
689685
errorMessage = errorMessage.replace(new RegExp(matches[1], 'g'), 'secret');
690686
}
691687
}
692688

693-
if (needsTranslate) {
694-
langKeys.push(errorMessage);
695-
}
696-
697-
$translate(langKeys).then(function(translations) {
698-
var message = $mmText.decodeHTML(needsTranslate ? translations[errorMessage] : errorMessage),
699-
popup = $ionicPopup.alert({
700-
title: $mmText.decodeHTML(translations[errorKey]),
701-
template: addFormatTextIfNeeded(message) // Add format-text to handle links.
702-
});
689+
var message = $mmText.decodeHTML(needsTranslate ? $translate.instant(errorMessage) : errorMessage),
690+
popup = $ionicPopup.alert({
691+
title: getErrorTitle(message),
692+
template: addFormatTextIfNeeded(message) // Add format-text to handle links.
693+
});
703694

704-
if (typeof autocloseTime != 'undefined' && !isNaN(parseInt(autocloseTime))) {
705-
$timeout(function() {
706-
popup.close();
707-
}, parseInt(autocloseTime));
708-
}
709-
});
695+
if (typeof autocloseTime != 'undefined' && !isNaN(parseInt(autocloseTime))) {
696+
$timeout(function() {
697+
popup.close();
698+
}, parseInt(autocloseTime));
699+
}
710700
};
711701

702+
function getErrorTitle(message) {
703+
if (message == $translate.instant('mm.core.networkerrormsg')) {
704+
return '<span class="mm-icon-with-badge"><i class="icon ion-wifi"></i>\
705+
<i class="icon ion-alert-circled mm-icon-badge"></i></span>';
706+
}
707+
return $mmText.decodeHTML($translate.instant('mm.core.error'));
708+
}
709+
712710
/**
713711
* Show a modal with an error message specifying a default message if error is empty.
714712
*

www/core/scss/styles.scss

Lines changed: 51 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -594,10 +594,25 @@ p.mm-error {
594594
box-shadow: $card-box-shadow;
595595
margin: 20px 10px;
596596
background-color: #fff;
597+
position: relative;
598+
padding-left: $item-padding * 3;
599+
text-align: left;
597600

598-
i.icon:before {
599-
color: $mm-warning-color;
600-
font-size: 125%;
601+
i.icon {
602+
@include display-flex();
603+
@include align-items(center);
604+
position: absolute;
605+
top: 0;
606+
height: 100%;
607+
font-size: ceil(($item-icon-font-size / 4) * 3);
608+
left: ceil($item-padding / 4);
609+
color: $mm-warning-color;
610+
611+
&:before {
612+
display: block;
613+
width: ceil(($item-icon-font-size / 4) * 3);
614+
text-align: center;
615+
}
601616
}
602617
}
603618

@@ -694,6 +709,28 @@ mm-timer {
694709
max-width: 100%;
695710
}
696711

712+
.popup-container .popup-title
713+
714+
715+
.mm-icon-with-badge {
716+
position: relative;
717+
718+
.icon {
719+
font-size: $button-large-icon-size;
720+
}
721+
722+
.mm-icon-badge {
723+
width: auto;
724+
height: auto;
725+
margin: 0;
726+
position: absolute;
727+
top: -18px;
728+
right: -8px;
729+
color: red;
730+
font-size: $button-large-icon-size / 2;
731+
}
732+
}
733+
697734
.popup-container.mm-nohead .popup-head {
698735
display: none;
699736
}
@@ -1207,6 +1244,17 @@ ion-spinner.mm-spinner-right {
12071244
}
12081245
}
12091246

1247+
.card .item-border,
1248+
.item-border {
1249+
&:first-child {
1250+
border-top: $item-border-width solid $item-light-border;
1251+
}
1252+
1253+
&:last-child {
1254+
border-bottom: $item-border-width solid $item-light-border;
1255+
}
1256+
}
1257+
12101258
// Video subtitles.
12111259
.platform-ios video::cue {
12121260
font-size: 12px;

0 commit comments

Comments
 (0)