Skip to content

Commit f024e6c

Browse files
committed
Make keys deletable. User should be able to delete keys with typos.
1 parent 7ccd93d commit f024e6c

File tree

6 files changed

+30
-3
lines changed

6 files changed

+30
-3
lines changed

resources/lang/en/manager.php

+1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@
55
'locale_placeholder' => 'Enter the locale you wish to edit. (example: en)',
66
'button' => 'Load',
77
'google' => 'Google Translate',
8+
'delete' => 'Delete',
89
];

resources/lang/nl/manager.php

+1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@
55
'locale_placeholder' => 'Geef de taal op die uw wilt bewerken. (bijvoorbeeld: nl)',
66
'button' => 'Inladen',
77
'google' => 'Google Translate',
8+
'delete' => 'Verwijderen',
89
];

src/Controllers/TranslationsController.php

+7
Original file line numberDiff line numberDiff line change
@@ -97,4 +97,11 @@ public function postTranslate(Request $request) {
9797
$key = $request->input('key');
9898
return compact('key', 'text');
9999
}
100+
101+
public function postDelete(Request $request)
102+
{
103+
\DB::table('translations')
104+
->where('name', strtolower($request->get('name')))->delete();
105+
return 'OK';
106+
}
100107
}

src/ServiceProvider.php

+4
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,10 @@ public function boot()
9494
'uses' => 'TranslationsController@postTranslate',
9595
'as' => 'translations.translate',
9696
]);
97+
$router->post('/delete', [
98+
'uses' => 'TranslationsController@postDelete',
99+
'as' => 'translations.delete',
100+
]);
97101
});
98102
}
99103

views/index.blade.php

+6-1
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,17 @@
7171
[[ item.name ]]
7272
<span ng-if="item.check == true" class="label label-warning">Unsaved!</span>
7373
</div>
74-
<div class="col-md-4 text">
74+
<div class="col-md-3 text">
7575
[[ item.value ]]
7676
</div>
7777
<div class="col-md-5">
7878
<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>
7979
</div>
80+
<div class="col-md-1">
81+
<button type="button" class="btn btn-danger" ng-click="delete($index)">
82+
{{ trans('translation::manager.delete') }}
83+
</button>
84+
</div>
8085
</div>
8186
</div>
8287

views/javascript.blade.php

+11-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
1818
$scope.clear = function() {
1919
$scope.items = [];
20-
}
20+
};
2121
2222
$scope.translateResult = {'total': 0, 'loading': 0, 'errors': 0, 'skip': 0, 'success': 0};
2323
$scope.translateAll = function() {
@@ -61,6 +61,14 @@
6161
.error(error);
6262
};
6363
64+
$scope.delete = function($index) {
65+
$http.post("{{ URL::route('translations.delete') }}", {
66+
'name': $scope.items[$index].name
67+
}).success(function() {
68+
$scope.items.splice($index, 1);
69+
});
70+
};
71+
6472
$scope.fetch = function() {
6573
$http.post("{{ URL::route('translations.items') }}", {
6674
'group': $scope.currentGroup,
@@ -85,7 +93,7 @@
8593
$scope.setMessage(status, 'danger');
8694
});
8795
$scope.items[$index].check = false;
88-
}
96+
};
8997
9098
$scope.locales = [];
9199
$scope.groups = [];
@@ -94,6 +102,7 @@
94102
$scope.currentEditable = null;
95103
$scope.items = [];
96104
$scope.message = null;
105+
$scope.showEmptyOnly = false;
97106
98107
$http.get("{{ URL::route('translations.locales') }}").success(function(data) {
99108
$scope.locales = data;

0 commit comments

Comments
 (0)