Skip to content

Commit

Permalink
Make keys deletable. User should be able to delete keys with typos.
Browse files Browse the repository at this point in the history
  • Loading branch information
hpolthof committed Sep 18, 2015
1 parent 7ccd93d commit f024e6c
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 3 deletions.
1 change: 1 addition & 0 deletions resources/lang/en/manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@
'locale_placeholder' => 'Enter the locale you wish to edit. (example: en)',
'button' => 'Load',
'google' => 'Google Translate',
'delete' => 'Delete',
];
1 change: 1 addition & 0 deletions resources/lang/nl/manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@
'locale_placeholder' => 'Geef de taal op die uw wilt bewerken. (bijvoorbeeld: nl)',
'button' => 'Inladen',
'google' => 'Google Translate',
'delete' => 'Verwijderen',
];
7 changes: 7 additions & 0 deletions src/Controllers/TranslationsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,11 @@ public function postTranslate(Request $request) {
$key = $request->input('key');
return compact('key', 'text');
}

public function postDelete(Request $request)
{
\DB::table('translations')
->where('name', strtolower($request->get('name')))->delete();
return 'OK';
}
}
4 changes: 4 additions & 0 deletions src/ServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ public function boot()
'uses' => 'TranslationsController@postTranslate',
'as' => 'translations.translate',
]);
$router->post('/delete', [
'uses' => 'TranslationsController@postDelete',
'as' => 'translations.delete',
]);
});
}

Expand Down
7 changes: 6 additions & 1 deletion views/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,17 @@
[[ item.name ]]
<span ng-if="item.check == true" class="label label-warning">Unsaved!</span>
</div>
<div class="col-md-4 text">
<div class="col-md-3 text">
[[ item.value ]]
</div>
<div class="col-md-5">
<textarea class="form-control" ng-blur="store($index)" ng-model="item.translation" onfocus="jQuery(this).closest('.row').addClass('bg-success');" onblur="jQuery(this).closest('.row').removeClass('bg-success');"></textarea>
</div>
<div class="col-md-1">
<button type="button" class="btn btn-danger" ng-click="delete($index)">
{{ trans('translation::manager.delete') }}
</button>
</div>
</div>
</div>

Expand Down
13 changes: 11 additions & 2 deletions views/javascript.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
$scope.clear = function() {
$scope.items = [];
}
};
$scope.translateResult = {'total': 0, 'loading': 0, 'errors': 0, 'skip': 0, 'success': 0};
$scope.translateAll = function() {
Expand Down Expand Up @@ -61,6 +61,14 @@
.error(error);
};
$scope.delete = function($index) {
$http.post("{{ URL::route('translations.delete') }}", {
'name': $scope.items[$index].name
}).success(function() {
$scope.items.splice($index, 1);
});
};
$scope.fetch = function() {
$http.post("{{ URL::route('translations.items') }}", {
'group': $scope.currentGroup,
Expand All @@ -85,7 +93,7 @@
$scope.setMessage(status, 'danger');
});
$scope.items[$index].check = false;
}
};
$scope.locales = [];
$scope.groups = [];
Expand All @@ -94,6 +102,7 @@
$scope.currentEditable = null;
$scope.items = [];
$scope.message = null;
$scope.showEmptyOnly = false;
$http.get("{{ URL::route('translations.locales') }}").success(function(data) {
$scope.locales = data;
Expand Down

0 comments on commit f024e6c

Please sign in to comment.