|
1643 | 1643 | success: function (jsonAccounts) { |
1644 | 1644 | var accountByName = {}; |
1645 | 1645 | $.each(jsonAccounts.listaccountsresponse.account, function(idx, account) { |
1646 | | - // Only add current domain's accounts as update template permissions supports that |
1647 | | - if (account.domainid === g_domainid) { |
| 1646 | + // Only add current domain's accounts for add as update template permissions supports that |
| 1647 | + if (account.domainid === g_domainid && operation === "add") { |
1648 | 1648 | accountByName[account.name] = { |
1649 | 1649 | projName: account.name, |
1650 | 1650 | hasPermission: false |
|
1658 | 1658 | success: function (json) { |
1659 | 1659 | items = json.listtemplatepermissionsresponse.templatepermission.account; |
1660 | 1660 | $.each(items, function(idx, accountName) { |
1661 | | - accountByName[accountName].hasPermission = true; |
| 1661 | + if (accountByName[accountName]) { |
| 1662 | + accountByName[accountName].hasPermission = true; |
| 1663 | + } |
1662 | 1664 | }); |
1663 | 1665 |
|
1664 | 1666 | var accountObjs = []; |
|
1707 | 1709 | success: function (jsonProjects) { |
1708 | 1710 | var projectsByIds = {}; |
1709 | 1711 | $.each(jsonProjects.listprojectsresponse.project, function(idx, project) { |
1710 | | - // Only add current domain's projects as update template permissions supports that |
1711 | | - if (project.domainid === g_domainid) { |
| 1712 | + // Only add current domain's projects for add operation as update template permissions supports that |
| 1713 | + if ((project.domainid === g_domainid && operation === "add") || operation === "remove") { |
1712 | 1714 | projectsByIds[project.id] = { |
1713 | 1715 | projName: project.name, |
1714 | 1716 | hasPermission: false |
|
1723 | 1725 | success: function (json) { |
1724 | 1726 | items = json.listtemplatepermissionsresponse.templatepermission.projectids; |
1725 | 1727 | $.each(items, function(idx, projectId) { |
1726 | | - projectsByIds[projectId].hasPermission = true; |
| 1728 | + if (projectsByIds[projectId]) { |
| 1729 | + projectsByIds[projectId].hasPermission = true; |
| 1730 | + } |
1727 | 1731 | }); |
1728 | 1732 |
|
1729 | 1733 | var projectObjs = []; |
|
0 commit comments