rails_admin_image_manager 0.1.20 → 0.1.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/assets/javascripts/rails_admin_image_manager/app-compiled.js.erb +57 -33
- data/app/assets/javascripts/rails_admin_image_manager/components/imageListing.vue +6 -6
- data/app/assets/javascripts/rails_admin_image_manager/router/index.js +8 -1
- data/app/assets/javascripts/rails_admin_image_manager/stores/medias.js +15 -2
- data/app/controllers/rails_admin_image_manager/application_controller.rb +18 -1
- data/app/controllers/rails_admin_image_manager/images_controller.rb +26 -4
- data/config/routes.rb +1 -0
- data/lib/paperclip_patch.rb +2 -0
- data/lib/rails_admin_image_manager/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ce5292868f557c84909e5db795e5080722c679c5
|
4
|
+
data.tar.gz: fc6a76688fb37392583c18a4cedd39275a463f3a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2db417829eb63be80bb0b8592f7bf1f5d8c9c696ad6d116a292438e64f3ab7cbe6d9de022b57c2cc90b3f14ae3a4992efd4672c77199a09c57a3031e8213150b
|
7
|
+
data.tar.gz: de796a632d45e02734c7f3d2f1aa665488cfe84c7d2ea49000703311f0d1060579820326514e3ac000d576328da173c068066a2a56ab8d3a53158384cb286492
|
@@ -11605,8 +11605,15 @@
|
|
11605
11605
|
name: 'createImage',
|
11606
11606
|
component: _imageShow2.default,
|
11607
11607
|
beforeEnter: function beforeEnter(to, from, next) {
|
11608
|
+
_stores2.default.dispatch('overlayStore/showProgressOverlay', true);
|
11608
11609
|
_stores2.default.dispatch('mediasStore/clearCurrentImg');
|
11609
|
-
|
11610
|
+
_stores2.default.dispatch('mediasStore/checkAddMediaPermission').then(function () {
|
11611
|
+
_stores2.default.dispatch('overlayStore/showProgressOverlay', false);
|
11612
|
+
next();
|
11613
|
+
}).catch(function () {
|
11614
|
+
_stores2.default.dispatch('overlayStore/showProgressOverlay', false);
|
11615
|
+
_stores2.default.dispatch('overlayStore/pushNotification', { error: true, msg: 'Vous n\'avez pas les permissions d\'ajouter un media' }, { root: true });
|
11616
|
+
});
|
11610
11617
|
}
|
11611
11618
|
}]
|
11612
11619
|
});
|
@@ -14775,7 +14782,7 @@
|
|
14775
14782
|
};
|
14776
14783
|
},
|
14777
14784
|
|
14778
|
-
computed: _extends({}, (0, _vuex.mapState)('mediasStore', ['imageListItems', 'maxImageListItems', 'tags', 'activeFilters'])),
|
14785
|
+
computed: _extends({}, (0, _vuex.mapState)('mediasStore', ['imageListItems', 'maxImageListItems', 'tags', 'activeFilters', 'readOnly'])),
|
14779
14786
|
methods: {
|
14780
14787
|
fetchImage: function fetchImage() {
|
14781
14788
|
var _this2 = this;
|
@@ -32693,7 +32700,7 @@
|
|
32693
32700
|
staticClass: "row"
|
32694
32701
|
}, [_c('div', {
|
32695
32702
|
staticClass: "col-sm-6"
|
32696
|
-
}, [_c('p', [_c('router-link', {
|
32703
|
+
}, [_c('p', [(!_vm.readOnly) ? _c('router-link', {
|
32697
32704
|
staticClass: "btn btn-primary",
|
32698
32705
|
attrs: {
|
32699
32706
|
"to": {
|
@@ -32702,7 +32709,7 @@
|
|
32702
32709
|
}
|
32703
32710
|
}, [_c('i', {
|
32704
32711
|
staticClass: "fa fa-plus"
|
32705
|
-
}), _vm._v(" Ajouter une image")]), _vm._v(" "), (_vm.searchedQuery || _vm.selectedFilter) ? _c('button', {
|
32712
|
+
}), _vm._v(" Ajouter une image")]) : _vm._e(), _vm._v(" "), (_vm.searchedQuery || _vm.selectedFilter) ? _c('button', {
|
32706
32713
|
staticClass: "btn btn-default",
|
32707
32714
|
on: {
|
32708
32715
|
"click": _vm.resetSearchAndFilters
|
@@ -32728,7 +32735,7 @@
|
|
32728
32735
|
staticClass: "img-options-content"
|
32729
32736
|
}, [_c('h4', {
|
32730
32737
|
staticClass: "h6 font-w400 text-white-op push-15"
|
32731
|
-
}, [_vm._v(_vm._s(image.name))]), _vm._v(" "), _c('router-link', {
|
32738
|
+
}, [_vm._v(_vm._s(image.name))]), _vm._v(" "), (!_vm.readOnly) ? _c('router-link', {
|
32732
32739
|
staticClass: "btn btn-sm btn-default",
|
32733
32740
|
attrs: {
|
32734
32741
|
"to": {
|
@@ -32738,11 +32745,11 @@
|
|
32738
32745
|
}
|
32739
32746
|
}
|
32740
32747
|
}
|
32741
|
-
}, [_vm._v("Modifier")]), _vm._v(" "), _c('image-insert-button', {
|
32748
|
+
}, [_vm._v("Modifier")]) : _vm._e(), _vm._v(" "), _c('image-insert-button', {
|
32742
32749
|
attrs: {
|
32743
32750
|
"id": image.id
|
32744
32751
|
}
|
32745
|
-
}), _vm._v(" "), _c('a', {
|
32752
|
+
}), _vm._v(" "), (!_vm.readOnly) ? _c('a', {
|
32746
32753
|
staticClass: "btn btn-sm btn-default",
|
32747
32754
|
attrs: {
|
32748
32755
|
"href": "javascript:void(0)"
|
@@ -32752,7 +32759,7 @@
|
|
32752
32759
|
_vm.deleteImage(image)
|
32753
32760
|
}
|
32754
32761
|
}
|
32755
|
-
}, [_vm._v("Supprimer")])], 1)])])])
|
32762
|
+
}, [_vm._v("Supprimer")]) : _vm._e()], 1)])])])
|
32756
32763
|
})) : _vm._e(), _vm._v(" "), (!_vm.grid) ? _c('div', {
|
32757
32764
|
staticClass: "row items-push"
|
32758
32765
|
}, [_c('div', {
|
@@ -32804,7 +32811,7 @@
|
|
32804
32811
|
attrs: {
|
32805
32812
|
"id": image.id
|
32806
32813
|
}
|
32807
|
-
}), _vm._v(" "), _c('router-link', {
|
32814
|
+
}), _vm._v(" "), (!_vm.readOnly) ? _c('router-link', {
|
32808
32815
|
staticClass: "btn btn-xs btn-default",
|
32809
32816
|
attrs: {
|
32810
32817
|
"to": {
|
@@ -32816,7 +32823,7 @@
|
|
32816
32823
|
}
|
32817
32824
|
}, [_c('i', {
|
32818
32825
|
staticClass: "fa fa-edit"
|
32819
|
-
})]), _vm._v(" "), _c('a', {
|
32826
|
+
})]) : _vm._e(), _vm._v(" "), (!_vm.readOnly) ? _c('a', {
|
32820
32827
|
staticClass: "btn btn-xs btn-default",
|
32821
32828
|
attrs: {
|
32822
32829
|
"href": "javascript:void(0)"
|
@@ -32828,7 +32835,7 @@
|
|
32828
32835
|
}
|
32829
32836
|
}, [_c('i', {
|
32830
32837
|
staticClass: "fa fa-trash-o"
|
32831
|
-
})])], 1)])
|
32838
|
+
})]) : _vm._e()], 1)])
|
32832
32839
|
}))])])]) : _vm._e(), _vm._v(" "), _c('div', {
|
32833
32840
|
staticClass: "row text-center items-push"
|
32834
32841
|
}, [_c('div', {
|
@@ -33533,6 +33540,7 @@
|
|
33533
33540
|
currentImgSrc: "",
|
33534
33541
|
currentImgTags: [],
|
33535
33542
|
imageListItems: [],
|
33543
|
+
readOnly: false,
|
33536
33544
|
maxImageListItems: -1,
|
33537
33545
|
activeFilters: {
|
33538
33546
|
tags: [],
|
@@ -33545,6 +33553,9 @@
|
|
33545
33553
|
errors: {}
|
33546
33554
|
},
|
33547
33555
|
mutations: {
|
33556
|
+
UPDATE_READ_ONLY: function UPDATE_READ_ONLY(state, readOnly) {
|
33557
|
+
state.readOnly = readOnly;
|
33558
|
+
},
|
33548
33559
|
UPDATE_CURRENT_IMG_ID: function UPDATE_CURRENT_IMG_ID(state, id) {
|
33549
33560
|
state.currentImgId = id;
|
33550
33561
|
},
|
@@ -33765,6 +33776,7 @@
|
|
33765
33776
|
if (state.maxImageListItems == -1) commit('SET_MAX_IMAGE_LIST_ITEMS', response.data.total_count);
|
33766
33777
|
// Calling mutation
|
33767
33778
|
commit('ADD_TO_LIST_ITEMS', response.data.items);
|
33779
|
+
commit('UPDATE_READ_ONLY', response.data.readonly);
|
33768
33780
|
|
33769
33781
|
// Hiding progess bar
|
33770
33782
|
dispatch('overlayStore/showProgressOverlay', false, { root: true });
|
@@ -33784,12 +33796,14 @@
|
|
33784
33796
|
},
|
33785
33797
|
fetchSingleImage: function fetchSingleImage(_ref8, id) {
|
33786
33798
|
var dispatch = _ref8.dispatch,
|
33787
|
-
rootDispatch = _ref8.rootDispatch
|
33799
|
+
rootDispatch = _ref8.rootDispatch,
|
33800
|
+
commit = _ref8.commit;
|
33788
33801
|
|
33789
33802
|
dispatch('overlayStore/showProgressOverlay', true, { root: true });
|
33790
33803
|
return new Promise(function (resolve, reject) {
|
33791
33804
|
_axios2.default.get('/images/' + id).then(function (response) {
|
33792
|
-
|
33805
|
+
commit('UPDATE_READ_ONLY', response.data.readonly);
|
33806
|
+
dispatch('setCurrentImg', response.data.image);
|
33793
33807
|
dispatch('overlayStore/showProgressOverlay', false, { root: true });
|
33794
33808
|
resolve();
|
33795
33809
|
}).catch(function () {
|
@@ -33841,45 +33855,55 @@
|
|
33841
33855
|
dispatch('overlayStore/pushNotification', { error: true, msg: 'Problème lors de la supression de l\'image' }, { root: true });
|
33842
33856
|
});
|
33843
33857
|
});
|
33844
|
-
}), _defineProperty(_actions, '
|
33858
|
+
}), _defineProperty(_actions, 'checkAddMediaPermission', function checkAddMediaPermission(_ref12) {
|
33845
33859
|
var commit = _ref12.commit;
|
33846
33860
|
|
33847
|
-
|
33848
|
-
|
33861
|
+
return new Promise(function (resolve, reject) {
|
33862
|
+
_axios2.default.get('/images/new').then(function () {
|
33863
|
+
resolve();
|
33864
|
+
}).catch(function () {
|
33865
|
+
reject();
|
33866
|
+
});
|
33867
|
+
});
|
33868
|
+
}), _defineProperty(_actions, 'setSearchPage', function setSearchPage(_ref13, page) {
|
33849
33869
|
var commit = _ref13.commit;
|
33850
33870
|
|
33871
|
+
commit('SET_PAGE', page);
|
33872
|
+
}), _defineProperty(_actions, 'setSearchQuery', function setSearchQuery(_ref14, query) {
|
33873
|
+
var commit = _ref14.commit;
|
33874
|
+
|
33851
33875
|
commit('SET_QUERY', query);
|
33852
|
-
}), _defineProperty(_actions, 'toggleFilter', function toggleFilter(
|
33853
|
-
var commit =
|
33854
|
-
state =
|
33876
|
+
}), _defineProperty(_actions, 'toggleFilter', function toggleFilter(_ref15, type) {
|
33877
|
+
var commit = _ref15.commit,
|
33878
|
+
state = _ref15.state;
|
33855
33879
|
|
33856
33880
|
var term = state.activeFilters[type] == 'ASC' ? 'DESC' : 'ASC';
|
33857
33881
|
commit('SET_FILTER', [term, type]);
|
33858
|
-
}), _defineProperty(_actions, 'clearImgListing', function clearImgListing(
|
33859
|
-
var commit =
|
33882
|
+
}), _defineProperty(_actions, 'clearImgListing', function clearImgListing(_ref16) {
|
33883
|
+
var commit = _ref16.commit;
|
33860
33884
|
|
33861
33885
|
commit('CLEAR_IMG_LISTING');
|
33862
|
-
}), _defineProperty(_actions, 'updateSrc', function updateSrc(
|
33863
|
-
var commit = _ref16.commit,
|
33864
|
-
state = _ref16.state;
|
33865
|
-
|
33866
|
-
commit('UPDATE_CURRENT_IMG_SRC', src);
|
33867
|
-
}), _defineProperty(_actions, 'addToTagFilter', function addToTagFilter(_ref17, id) {
|
33886
|
+
}), _defineProperty(_actions, 'updateSrc', function updateSrc(_ref17, src) {
|
33868
33887
|
var commit = _ref17.commit,
|
33869
33888
|
state = _ref17.state;
|
33870
33889
|
|
33871
|
-
commit('
|
33872
|
-
}), _defineProperty(_actions, '
|
33890
|
+
commit('UPDATE_CURRENT_IMG_SRC', src);
|
33891
|
+
}), _defineProperty(_actions, 'addToTagFilter', function addToTagFilter(_ref18, id) {
|
33873
33892
|
var commit = _ref18.commit,
|
33874
33893
|
state = _ref18.state;
|
33875
33894
|
|
33895
|
+
commit('ADD_TO_TAG_FILTERS', id);
|
33896
|
+
}), _defineProperty(_actions, 'removeFromTagFilter', function removeFromTagFilter(_ref19, id) {
|
33897
|
+
var commit = _ref19.commit,
|
33898
|
+
state = _ref19.state;
|
33899
|
+
|
33876
33900
|
commit('REMOVE_FROM_TAG_FILTERS', id);
|
33877
|
-
}), _defineProperty(_actions, 'addTag', function addTag(
|
33878
|
-
var commit =
|
33901
|
+
}), _defineProperty(_actions, 'addTag', function addTag(_ref20, string) {
|
33902
|
+
var commit = _ref20.commit;
|
33879
33903
|
|
33880
33904
|
commit('ADD_CURRENT_IMG_TAG', string);
|
33881
|
-
}), _defineProperty(_actions, 'removeTag', function removeTag(
|
33882
|
-
var commit =
|
33905
|
+
}), _defineProperty(_actions, 'removeTag', function removeTag(_ref21, string) {
|
33906
|
+
var commit = _ref21.commit;
|
33883
33907
|
|
33884
33908
|
commit('REMOVE_CURRENT_IMG_TAG', string);
|
33885
33909
|
}), _actions)
|
@@ -9,7 +9,7 @@
|
|
9
9
|
<div class="row">
|
10
10
|
<div class="col-sm-6">
|
11
11
|
<p>
|
12
|
-
<router-link class="btn btn-primary" :to="{ name: 'createImage'}"><i class="fa fa-plus"></i> Ajouter une image</router-link>
|
12
|
+
<router-link v-if="!readOnly" class="btn btn-primary" :to="{ name: 'createImage'}"><i class="fa fa-plus"></i> Ajouter une image</router-link>
|
13
13
|
<button v-if="searchedQuery || selectedFilter" @click="resetSearchAndFilters" class="btn btn-default" ><i class="fa fa-undo"></i> Annuler la recherche</button>
|
14
14
|
</p>
|
15
15
|
|
@@ -24,9 +24,9 @@
|
|
24
24
|
<div class="img-options">
|
25
25
|
<div class="img-options-content">
|
26
26
|
<h4 class="h6 font-w400 text-white-op push-15">{{ image.name }}</h4>
|
27
|
-
<router-link class="btn btn-sm btn-default" :to="{ name: 'showImage', params: { id: image.id }}">Modifier</router-link>
|
27
|
+
<router-link v-if="!readOnly" class="btn btn-sm btn-default" :to="{ name: 'showImage', params: { id: image.id }}">Modifier</router-link>
|
28
28
|
<image-insert-button :id="image.id"/>
|
29
|
-
<a class="btn btn-sm btn-default" @click="deleteImage(image)" href="javascript:void(0)">Supprimer</a>
|
29
|
+
<a v-if="!readOnly" class="btn btn-sm btn-default" @click="deleteImage(image)" href="javascript:void(0)">Supprimer</a>
|
30
30
|
</div>
|
31
31
|
</div>
|
32
32
|
</div>
|
@@ -54,8 +54,8 @@
|
|
54
54
|
<td>{{ image.created_at | formatDate }}</td>
|
55
55
|
<td class="text-right">
|
56
56
|
<image-insert-button :id="image.id"/>
|
57
|
-
<router-link class="btn btn-xs btn-default" :to="{ name: 'showImage', params: { id: image.id }}"><i class="fa fa-edit"></i></router-link>
|
58
|
-
<a class="btn btn-xs btn-default" @click="deleteImage(image)" href="javascript:void(0)"><i class="fa fa-trash-o"></i></a>
|
57
|
+
<router-link v-if="!readOnly" class="btn btn-xs btn-default" :to="{ name: 'showImage', params: { id: image.id }}"><i class="fa fa-edit"></i></router-link>
|
58
|
+
<a v-if="!readOnly" class="btn btn-xs btn-default" @click="deleteImage(image)" href="javascript:void(0)"><i class="fa fa-trash-o"></i></a>
|
59
59
|
</td>
|
60
60
|
</tr>
|
61
61
|
</tbody>
|
@@ -98,7 +98,7 @@ export default {
|
|
98
98
|
}
|
99
99
|
},
|
100
100
|
computed: {
|
101
|
-
...mapState('mediasStore', ['imageListItems', 'maxImageListItems', 'tags', 'activeFilters'])
|
101
|
+
...mapState('mediasStore', ['imageListItems', 'maxImageListItems', 'tags', 'activeFilters', 'readOnly'])
|
102
102
|
},
|
103
103
|
methods:{
|
104
104
|
fetchImage() {
|
@@ -38,8 +38,15 @@ let router = new Router({
|
|
38
38
|
name: 'createImage',
|
39
39
|
component: imageShow,
|
40
40
|
beforeEnter: (to, from, next) => {
|
41
|
+
store.dispatch('overlayStore/showProgressOverlay', true)
|
41
42
|
store.dispatch('mediasStore/clearCurrentImg')
|
42
|
-
|
43
|
+
store.dispatch('mediasStore/checkAddMediaPermission').then(()=> {
|
44
|
+
store.dispatch('overlayStore/showProgressOverlay', false)
|
45
|
+
next()
|
46
|
+
}).catch(() => {
|
47
|
+
store.dispatch('overlayStore/showProgressOverlay', false)
|
48
|
+
store.dispatch('overlayStore/pushNotification', {error: true, msg: `Vous n'avez pas les permissions d'ajouter un media`}, {root:true})
|
49
|
+
})
|
43
50
|
}
|
44
51
|
}
|
45
52
|
]
|
@@ -11,6 +11,7 @@ const mediasStore = {
|
|
11
11
|
currentImgSrc: "",
|
12
12
|
currentImgTags: [],
|
13
13
|
imageListItems: [],
|
14
|
+
readOnly: false,
|
14
15
|
maxImageListItems: -1,
|
15
16
|
activeFilters: {
|
16
17
|
tags: [],
|
@@ -23,6 +24,9 @@ const mediasStore = {
|
|
23
24
|
errors: {}
|
24
25
|
},
|
25
26
|
mutations: {
|
27
|
+
UPDATE_READ_ONLY (state, readOnly) {
|
28
|
+
state.readOnly = readOnly
|
29
|
+
},
|
26
30
|
UPDATE_CURRENT_IMG_ID (state, id) {
|
27
31
|
state.currentImgId = id
|
28
32
|
},
|
@@ -214,6 +218,7 @@ const mediasStore = {
|
|
214
218
|
if(state.maxImageListItems == -1) commit('SET_MAX_IMAGE_LIST_ITEMS', response.data.total_count)
|
215
219
|
// Calling mutation
|
216
220
|
commit('ADD_TO_LIST_ITEMS', response.data.items)
|
221
|
+
commit('UPDATE_READ_ONLY', response.data.readonly)
|
217
222
|
|
218
223
|
// Hiding progess bar
|
219
224
|
dispatch('overlayStore/showProgressOverlay', false, {root:true})
|
@@ -231,12 +236,13 @@ const mediasStore = {
|
|
231
236
|
})
|
232
237
|
})
|
233
238
|
},
|
234
|
-
fetchSingleImage({ dispatch, rootDispatch}, id) {
|
239
|
+
fetchSingleImage({ dispatch, rootDispatch, commit}, id) {
|
235
240
|
dispatch('overlayStore/showProgressOverlay', true, {root:true})
|
236
241
|
return new Promise((resolve, reject) => {
|
237
242
|
axios.get(`/images/${id}`)
|
238
243
|
.then((response) => {
|
239
|
-
|
244
|
+
commit('UPDATE_READ_ONLY', response.data.readonly)
|
245
|
+
dispatch('setCurrentImg', response.data.image)
|
240
246
|
dispatch('overlayStore/showProgressOverlay', false, {root:true})
|
241
247
|
resolve()
|
242
248
|
})
|
@@ -286,6 +292,13 @@ const mediasStore = {
|
|
286
292
|
})
|
287
293
|
})
|
288
294
|
},
|
295
|
+
checkAddMediaPermission({commit}) {
|
296
|
+
return new Promise(function(resolve, reject) {
|
297
|
+
axios.get(`/images/new`)
|
298
|
+
.then(() => { resolve() })
|
299
|
+
.catch(() => { reject() })
|
300
|
+
})
|
301
|
+
},
|
289
302
|
setSearchPage({commit}, page) {
|
290
303
|
commit('SET_PAGE', page)
|
291
304
|
},
|
@@ -1,10 +1,15 @@
|
|
1
1
|
module RailsAdminImageManager
|
2
|
-
class ApplicationController <
|
2
|
+
class ApplicationController < ActionController::Base
|
3
3
|
|
4
4
|
protect_from_forgery with: :exception
|
5
5
|
|
6
6
|
before_action :_authenticate!
|
7
7
|
before_action :_authorize!
|
8
|
+
before_action :_check_permissions
|
9
|
+
|
10
|
+
def _current_user
|
11
|
+
instance_eval(&RailsAdmin::Config.current_user_method)
|
12
|
+
end
|
8
13
|
|
9
14
|
private
|
10
15
|
|
@@ -16,6 +21,18 @@ module RailsAdminImageManager
|
|
16
21
|
instance_eval(&RailsAdmin::Config.authorize_with)
|
17
22
|
end
|
18
23
|
|
24
|
+
def _check_permissions(action=:read)
|
25
|
+
@authorization_adapter.try(:authorize, action, file_model)
|
26
|
+
end
|
27
|
+
|
28
|
+
def file_model
|
29
|
+
RailsAdmin::AbstractModel.new(to_model_name("::RailsAdminImageManager::File"))
|
30
|
+
end
|
31
|
+
|
32
|
+
def to_model_name(param)
|
33
|
+
param.split('~').collect(&:camelize).join('::')
|
34
|
+
end
|
35
|
+
|
19
36
|
def filter_by?(param)
|
20
37
|
params[param].present?
|
21
38
|
end
|
@@ -8,22 +8,23 @@ module RailsAdminImageManager
|
|
8
8
|
}
|
9
9
|
|
10
10
|
format.json {
|
11
|
-
images = RailsAdminImageManager::File.select(:id, :name, :image_file_name, :created_at).page(params[:page])
|
11
|
+
images = RailsAdminImageManager::File.select(:id, :name, :image_file_name, :created_at).order(:name).page(params[:page])
|
12
12
|
images = images.filter_by_text(params[:search]) if filter_by?(:search)
|
13
13
|
images = images.filter_by_tags(params[:tags].map{|i| i.to_i }) if filter_by?(:tags)
|
14
14
|
images = images.order_by_date(params[:date]) if filter_by?(:date)
|
15
15
|
images = images.order_by_title(params[:title]) if filter_by?(:title)
|
16
16
|
|
17
17
|
images.each do |image|
|
18
|
-
|
18
|
+
image.src = image.image.url(:index)
|
19
19
|
end
|
20
20
|
|
21
|
-
data = { items: images, total_count: images.total_count, limit_value: images.limit_value }
|
21
|
+
data = { items: images, total_count: images.total_count, limit_value: images.limit_value, readonly: readonly? }
|
22
22
|
|
23
23
|
render json: data, methods: [:src, :tags_list], status: :ok
|
24
24
|
}
|
25
25
|
end
|
26
26
|
end
|
27
|
+
|
27
28
|
def tags
|
28
29
|
respond_to do |format|
|
29
30
|
format.json {
|
@@ -33,15 +34,26 @@ module RailsAdminImageManager
|
|
33
34
|
end
|
34
35
|
end
|
35
36
|
|
37
|
+
def new
|
38
|
+
_check_permissions(:create)
|
39
|
+
render json: {msg: 'ok'}, status: :ok
|
40
|
+
end
|
41
|
+
|
36
42
|
def show
|
43
|
+
_check_permissions(:update)
|
44
|
+
|
37
45
|
image = RailsAdminImageManager::File.select(:id, :name, :description, :copyright, :image_file_name).find_by!(id: params[:id])
|
38
46
|
image.src = image.image.url(:show)
|
39
47
|
image.src_for_wysiwyg = {width: params[:width], height: params[:height]} if filter_by?(:width) && filter_by?(:height)
|
40
48
|
|
41
|
-
|
49
|
+
data = { image: image, readonly: readonly? }
|
50
|
+
|
51
|
+
render json: data, methods: [:src, :src_for_wysiwyg, :tags_list], status: :ok
|
42
52
|
end
|
43
53
|
|
44
54
|
def update
|
55
|
+
_check_permissions(:update)
|
56
|
+
|
45
57
|
my_params = images_params
|
46
58
|
image = RailsAdminImageManager::File.find(my_params[:id])
|
47
59
|
|
@@ -61,6 +73,8 @@ module RailsAdminImageManager
|
|
61
73
|
end
|
62
74
|
|
63
75
|
def create
|
76
|
+
_check_permissions(:create)
|
77
|
+
|
64
78
|
my_params = images_params
|
65
79
|
|
66
80
|
# Handling dynamic tag creating when receiving a string
|
@@ -79,13 +93,21 @@ module RailsAdminImageManager
|
|
79
93
|
end
|
80
94
|
|
81
95
|
def destroy
|
96
|
+
_check_permissions(:destroy)
|
97
|
+
|
82
98
|
image = RailsAdminImageManager::File.find(params[:id])
|
83
99
|
if image.destroy
|
84
100
|
render json: image, status: :ok
|
85
101
|
else
|
86
102
|
render json: image.errors, status: :unprocessable_entity
|
87
103
|
end
|
104
|
+
end
|
105
|
+
|
106
|
+
private
|
88
107
|
|
108
|
+
def readonly?
|
109
|
+
return false if @authorization_adapter.nil?
|
110
|
+
!@authorization_adapter.authorized?(:update, file_model)
|
89
111
|
end
|
90
112
|
|
91
113
|
def images_params
|
data/config/routes.rb
CHANGED
@@ -3,6 +3,7 @@ RailsAdminImageManager::Engine.routes.draw do
|
|
3
3
|
root 'home#index'
|
4
4
|
get '/tags' => 'images#tags', as: 'image_manager_tag_index'
|
5
5
|
get '/images' => 'images#index', as: 'image_manager_index'
|
6
|
+
get '/images/new' => 'images#new'
|
6
7
|
get '/images/:id' => 'images#show'
|
7
8
|
put '/images' => 'images#update'
|
8
9
|
post '/images' => 'images#create'
|
data/lib/paperclip_patch.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_admin_image_manager
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.21
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- iXmedia
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-09-
|
11
|
+
date: 2017-09-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|