mirror of
https://github.com/bitwarden/web
synced 2025-12-10 13:23:15 +00:00
Added delete option to edit site modal #25
This commit is contained in:
@@ -77,13 +77,25 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
editModel.result.then(function (editedSite) {
|
editModel.result.then(function (returnVal) {
|
||||||
var site = $filter('filter')($scope.sites, { id: editedSite.id }, true);
|
if (returnVal.action === 'edit') {
|
||||||
if (site && site.length > 0) {
|
var siteToUpdate = $filter('filter')($scope.sites, { id: returnVal.data.id }, true);
|
||||||
site[0].folderId = editedSite.folderId;
|
|
||||||
site[0].name = editedSite.name;
|
if (siteToUpdate && siteToUpdate.length > 0) {
|
||||||
site[0].username = editedSite.username;
|
siteToUpdate[0].folderId = returnVal.data.folderId;
|
||||||
site[0].favorite = editedSite.favorite;
|
siteToUpdate[0].name = returnVal.data.name;
|
||||||
|
siteToUpdate[0].username = returnVal.data.username;
|
||||||
|
siteToUpdate[0].favorite = returnVal.data.favorite;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (returnVal.action === 'delete') {
|
||||||
|
var siteToDelete = $filter('filter')($scope.sites, { id: returnVal.data }, true);
|
||||||
|
if (siteToDelete && siteToDelete.length > 0) {
|
||||||
|
var index = $scope.sites.indexOf(siteToDelete[0]);
|
||||||
|
if (index > -1) {
|
||||||
|
$scope.sites.splice(index, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -15,7 +15,10 @@
|
|||||||
$scope.savePromise = apiService.sites.put({ id: siteId }, site, function (siteResponse) {
|
$scope.savePromise = apiService.sites.put({ id: siteId }, site, function (siteResponse) {
|
||||||
$analytics.eventTrack('Edited Site');
|
$analytics.eventTrack('Edited Site');
|
||||||
var decSite = cipherService.decryptSite(siteResponse);
|
var decSite = cipherService.decryptSite(siteResponse);
|
||||||
$uibModalInstance.close(decSite);
|
$uibModalInstance.close({
|
||||||
|
action: 'edit',
|
||||||
|
data: decSite
|
||||||
|
});
|
||||||
}).$promise;
|
}).$promise;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -49,6 +52,19 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$scope.delete = function () {
|
||||||
|
if (!confirm('Are you sure you want to delete this site (' + $scope.site.name + ')?')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
apiService.sites.del({ id: $scope.site.id }, function () {
|
||||||
|
$uibModalInstance.close({
|
||||||
|
action: 'delete',
|
||||||
|
data: $scope.site.id
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
$scope.close = function () {
|
$scope.close = function () {
|
||||||
$uibModalInstance.dismiss('cancel');
|
$uibModalInstance.dismiss('cancel');
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -97,5 +97,8 @@
|
|||||||
<i class="fa fa-refresh fa-spin loading-icon" ng-show="editSiteForm.$loading"></i>Save
|
<i class="fa fa-refresh fa-spin loading-icon" ng-show="editSiteForm.$loading"></i>Save
|
||||||
</button>
|
</button>
|
||||||
<button type="button" class="btn btn-default btn-flat" ng-click="close()">Close</button>
|
<button type="button" class="btn btn-default btn-flat" ng-click="close()">Close</button>
|
||||||
|
<button type="button" class="btn btn-link pull-right" ng-click="delete()" uib-tooltip="Delete">
|
||||||
|
<i class="fa fa-trash fa-lg"></i>
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|||||||
Reference in New Issue
Block a user