Skip to content
Browse files

Merge branch 'SAKIII-5176' of git://github.com/croby/3akai-ux into SA…

…KIII-5176

* 'SAKIII-5176' of git://github.com/croby/3akai-ux:
  SAKIII-5176 Change handling of the notfound items so they are not lost on save
  SAKIII-5176 Fixing issue with single item 'batch' request
  SAKIII-5176 Ignore any elements without data, as the user doesn't have permission to see them
  • Loading branch information...
2 parents 710ce7c + 5416572 commit 110134e8d27a564082b113f52ee0bd37682c1647 Nicolaas Matthijs committed
Showing with 11 additions and 21 deletions.
  1. +4 −1 dev/lib/sakai/sakai.api.content.js
  2. +7 −20 devwidgets/embedcontent/javascript/embedcontent.js
View
5 dev/lib/sakai/sakai.api.content.js
@@ -664,11 +664,14 @@ define(
* @param {Object} userid authorizable id for which we're checking presence in the library
*/
isContentInLibrary: function(content, userid){
+ if (!content) {
+ return false;
+ }
// check if the content is a collection and the ID is the same collection
var collectionId = false;
if (content.data && sakai_content.Collections.isCollection(content.data)) {
collectionId = sakai_content.Collections.getCollectionGroupId(content.data);
- } else if (content && sakai_content.Collections.isCollection(content)) {
+ } else if (sakai_content.Collections.isCollection(content)) {
collectionId = sakai_content.Collections.getCollectionGroupId(content);
}
if (collectionId === userid) {
View
27 devwidgets/embedcontent/javascript/embedcontent.js
@@ -387,8 +387,6 @@ require(["jquery", "sakai/sakai.api.core"], function($, sakai) {
$.each(selectedItems, function(i,item) {
if (item.path) {
itemsToSave.push(item.path);
- } else {
- itemsToSave.push({notfound:true});
}
});
var objectData = {
@@ -421,27 +419,15 @@ require(["jquery", "sakai/sakai.api.core"], function($, sakai) {
var ret = false;
var batchRequests = [];
for (var i = 0, j = data.items.length; i < j; i++) {
- if (data.items[i].notfound) {
- newItems.push({
- type: "notfound",
- name: $embedcontent_item_unavailable_text.text(),
- value: "notfound1" + i
- });
- if (newItems.length === data.items.length) {
- wData.items = newItems;
- ret = true;
- }
- } else {
- batchRequests.push({
- url: data.items[i] + ".2.json",
- method: "GET"
- });
- }
+ batchRequests.push({
+ url: data.items[i] + ".2.json",
+ method: "GET"
+ });
}
if (batchRequests.length > 0) {
sakai.api.Server.batch(batchRequests, function(success, response){
- if (success) {
+ if (success || batchRequests.length === 1) {
$.each(response.results, function(index, item){
if (item.success && item.body){
var newItem = createDataObject($.parseJSON(item.body));
@@ -450,7 +436,8 @@ require(["jquery", "sakai/sakai.api.core"], function($, sakai) {
newItems.push({
type: "notfound",
name: $embedcontent_item_unavailable_text.text(),
- value: "notfound2" + index
+ value: "notfound2" + index,
+ path: item.url.replace('.2.json', '')
});
}
});

0 comments on commit 110134e

Please sign in to comment.
Something went wrong with that request. Please try again.