Skip to content
This repository was archived by the owner on Jul 16, 2018. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions public/js/angular/controllers.js
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,10 @@ angular
return badge;
}

$scope.resetForm = function () {
$scope.badgeForm.slug.$setValidity("unique", true);
};

$scope.submit = function (isValid, badge) {
$scope.submitAttempt = true;
if (!isValid) {
Expand All @@ -489,6 +493,9 @@ angular
window.location = '/' + config.lang + '/badges/' + data.slug;
})
.error(function (err) {
if (err === 'badge with that `slug` already exists') {
$scope.badgeForm.slug.$setValidity("unique", false);
}
console.log(err);
});
};
Expand Down
7 changes: 6 additions & 1 deletion public/views/admin/create-update-badge.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,15 @@ <h2>Basic information</h2>
<input name="name" ng-model="badge.name" class="form-control" required>
<p class="help-block">e.g. Webmaker Mentor</p>
</div>
<div class="form-group" ng-class="hasError(badgeForm.slug)" ng-if="view != 'update'">
<label>Slug</label>
<input name="slug" ng-model="badge.slug" class="form-control" ng-change="resetForm()">
<span class="help-block" ng-show="badgeForm.slug.$invalid">This slug is taken already.</span>
</div>
<div class="form-group" ng-if="badge.slug">
<label>URL</label>
<p><a ng-if="badge.slug" class="btn btn-default btn-block btn-left" href="/badges/{{badge.slug}}">webmaker.org/badges/{{badge.slug}}</a></p>
<p class="help-block">Unfortunately, due to limitations in badgekit-api, you are currently unable to change this.</p>
<p class="help-block">Unfortunately, you are currently unable to update this once published.</p>
</div>
<div class="form-group" ng-class="hasError(badgeForm.imageUrl)">
<label>Image URL</label>
Expand Down