Skip to content

Commit fbf066d

Browse files
committed
added new image custom field
1 parent 3415d9b commit fbf066d

File tree

8 files changed

+160
-5
lines changed

8 files changed

+160
-5
lines changed

src/Darryldecode/Backend/Base/Registrar/Registrar.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class Registrar {
1313
/**
1414
* the laravel backend version
1515
*/
16-
const VERSION = '1.0';
16+
const VERSION = '1.0.5';
1717
const VERSION_NAME = 'Alpha';
1818

1919
/**

src/Darryldecode/Backend/Components/Dashboard/Views/info.blade.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
@section('content')
44

55
<div class="row" data-ng-controller="DashboardInfoController">
6-
<div class="col-lg-6 col-md-6">
6+
<div class="col-lg-12 col-md-12">
77
<div class="panel panel-default">
88
<div class="panel-heading">
99
<h3 class="panel-title">
@@ -30,7 +30,7 @@
3030
</div>
3131
</div>
3232
</div>
33-
<div class="col-lg-6 col-md-6">
33+
<div class="col-lg-12 col-md-12">
3434
<div class="panel panel-default">
3535
<div class="panel-heading">
3636
<h3 class="panel-title">

src/Darryldecode/Backend/Public/backend/cb/app/contents/controller.contents.js

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,62 @@ angular.module('cb.group').controller('ContentsController', ['$scope','$timeout'
212212
$scope.content.customFields[formGroup][galleryFieldName].splice(index,1);
213213
};
214214

215+
216+
/**
217+
* Image Custom Field
218+
*
219+
* if there is an image custom field to the current content,
220+
* below are the controls to show the media manager modal to choose
221+
* images from and to be added on this field
222+
*
223+
* @type {{}}
224+
*/
225+
$scope.image = {};
226+
$scope.image.limit = 1;
227+
228+
// shows the media modal so we can select files to be place on the image field
229+
$scope.image.showMediaModal = function (formGroup, imageFieldName) {
230+
231+
// lets define if its not yet define so we don't get errors
232+
if( ! $scope.content.customFields[formGroup] ) {
233+
$scope.content.customFields[formGroup] = {};
234+
}
235+
236+
// if the field is not yet filled or being initialize, this is probably a fresh field added to this content
237+
// so we will define it as an empty array so we can push items on it.
238+
if( (!$scope.content.customFields[formGroup][imageFieldName]) || ($scope.content.customFields[formGroup][imageFieldName].length==0) ) {
239+
$scope.content.customFields[formGroup][imageFieldName] = [];
240+
}
241+
242+
var m = $modal.open({
243+
templateUrl: BASE_URL + '/darryldecode/backend/cb/app/contents/modals/gallery.html',
244+
controller: 'GalleryModalController',
245+
size: 'lg'
246+
});
247+
248+
m.result.then(function (selectedFiles) {
249+
for(var prop in selectedFiles) {
250+
251+
if( $scope.image.limit > 1 ) continue;
252+
253+
if( selectedFiles[prop] == true ) {
254+
var imageSrc = STORAGE_URL + prop;
255+
$scope.content.customFields[formGroup][imageFieldName].push({
256+
relativePath: prop,
257+
fullPath: imageSrc
258+
});
259+
$scope.image.limit++;
260+
}
261+
}
262+
});
263+
};
264+
265+
// remove an image on a specific gallery
266+
$scope.image.remove = function (formGroup, imageFieldName) {
267+
$scope.content.customFields[formGroup][imageFieldName] = [];
268+
$scope.image.limit = 1;
269+
};
270+
215271
/**
216272
* Editor
217273
*

src/Darryldecode/Backend/Public/backend/cb/app/custom-fields/factory.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,13 +116,28 @@ angular.module('cb.customFields').factory('CustomFieldsFactory',['$http',functio
116116
]
117117
}
118118
},
119+
{
120+
label: "Image Field",
121+
key: "image",
122+
templateCreate: "/darryldecode/backend/cb/app/custom-fields/fields/create/image.html",
123+
templateDisplay: "/darryldecode/backend/cb/app/custom-fields/fields/display/image.html",
124+
data: {
125+
label: "Image",
126+
description: 'Some field description here..',
127+
name: '',
128+
value: '',
129+
disabled: false,
130+
required: true
131+
}
132+
},
119133
{
120134
label: "Gallery Field",
121135
key: "gallery",
122136
templateCreate: "/darryldecode/backend/cb/app/custom-fields/fields/create/gallery.html",
123137
templateDisplay: "/darryldecode/backend/cb/app/custom-fields/fields/display/gallery.html",
124138
data: {
125139
label: "My Gallery",
140+
description: 'Some field description here..',
126141
name: '',
127142
required: true,
128143
items: []

src/Darryldecode/Backend/Public/backend/cb/app/custom-fields/fields/create/gallery.html

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
<div>
2+
<div class="image-upload-description pull-left text-left">
3+
<h4>{{f.data.label}} {{(f.data.required) ? '*' : ''}}</h4>
4+
<p>{{f.data.description}}</p>
5+
</div>
6+
7+
<div class="clearfix"></div>
8+
29
<ul class="list-group">
310
<li data-ng-if="content.customFields[group.form_name][f.data.name].length==0" class="list-group-item"><div class="alert text-center">No items yet..</div></li>
411
<li data-ng-repeat="img in content.customFields[group.form_name][f.data.name] track by $index" class="list-group-item">
@@ -21,6 +28,6 @@
2128
</li>
2229
</ul>
2330
<div class="form-group text-right">
24-
<button data-ng-click="gallery.showMediaModal(group.form_name, f.data.name)" class="btn btn-default"><i class="fa fa-image"></i> Add Images</button>
31+
<button data-ng-click="gallery.showMediaModal(group.form_name, f.data.name)" class="btn btn-default"><i class="fa fa-image"></i> Add Gallery Images</button>
2532
</div>
2633
</div>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<div class="form-group text-right">
2+
<div>
3+
<div class="image-upload-description pull-left text-left">
4+
<h4>{{f.data.label}} {{(f.data.required) ? '*' : ''}}</h4>
5+
<p>{{f.data.description}}</p>
6+
</div>
7+
8+
<div class="clearfix"></div>
9+
10+
<!-- image preview -->
11+
<div data-ng-if="content.customFields[group.form_name][f.data.name].length" class="row text-left">
12+
<div class="col-lg-12 col-md-12 col-sm-12">
13+
<file-preview size="120" file-source="{{content.customFields[group.form_name][f.data.name][0].relativePath}}"></file-preview>
14+
</div>
15+
</div>
16+
17+
<div class="form-group text-right">
18+
<button data-ng-if="content.customFields[group.form_name][f.data.name].length" data-ng-click="image.remove(group.form_name, f.data.name)" class="btn btn-warning"><i class="fa fa-close"></i> remove</button>
19+
<button data-ng-if="!content.customFields[group.form_name][f.data.name].length" data-ng-click="image.showMediaModal(group.form_name, f.data.name)" class="btn btn-default"><i class="fa fa-image"></i> Add Image</button>
20+
</div>
21+
</div>
22+
</div>

src/Darryldecode/Backend/Public/backend/cb/app/custom-fields/fields/display/gallery.html

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,30 @@
66

77
<!-- delete field / edit field control -->
88
<span class="pull-right">
9+
<a href="" data-ng-click="fieldGroup.editField(f.key, $index)" class="btn btn-clear btn-xs">Edit</a>
910
<a href="" data-ng-click="fieldGroup.deleteField($index)" class="btn btn-clear btn-xs">Delete</a>
1011
</span>
1112

1213
<!-- actual field -->
13-
<button class="btn btn-default"><i class="fa fa-image"></i> Add Images</button>
14+
<div class="image-upload-description pull-left text-left">
15+
<h4>{{f.data.label}} {{(f.data.required) ? '*' : ''}}</h4>
16+
<p>{{f.data.description}}</p>
17+
</div>
18+
19+
<div class="clearfix"></div>
20+
21+
<!-- actual field -->
22+
<button class="btn btn-default"><i class="fa fa-image"></i> Add Gallery Images</button>
23+
24+
<!-- edit mode -->
25+
<div class="edit-field edit-field-{{f.key}}-{{$index}}">
26+
<div class="form-group text-left">
27+
<label>Label:</label>
28+
<textarea class="form-control" data-ng-model="f.data.label"></textarea>
29+
</div>
30+
<div class="form-group text-left">
31+
<label>Description:</label>
32+
<textarea class="form-control" data-ng-model="f.data.description"></textarea>
33+
</div>
34+
</div>
1435
</div>
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<div class="form-group text-right">
2+
<!-- sort field handle -->
3+
<div class="sort-handle">
4+
<i class="fa fa-arrows"></i>
5+
</div>
6+
7+
<!-- delete field / edit field control -->
8+
<span class="pull-right">
9+
<a href="" data-ng-click="fieldGroup.editField(f.key, $index)" class="btn btn-clear btn-xs">Edit</a>
10+
<a href="" data-ng-click="fieldGroup.deleteField($index)" class="btn btn-clear btn-xs">Delete</a>
11+
</span>
12+
13+
<!-- actual field -->
14+
<div class="image-upload-description pull-left text-left">
15+
<h4>{{f.data.label}} {{(f.data.required) ? '*' : ''}}</h4>
16+
<p>{{f.data.description}}</p>
17+
</div>
18+
19+
<div class="clearfix"></div>
20+
21+
<button class="btn btn-default"><i class="fa fa-image"></i> Add Image</button>
22+
23+
<!-- edit mode -->
24+
<div class="edit-field edit-field-{{f.key}}-{{$index}}">
25+
<div class="form-group text-left">
26+
<label>Label:</label>
27+
<textarea class="form-control" data-ng-model="f.data.label"></textarea>
28+
</div>
29+
<div class="form-group text-left">
30+
<label>Description:</label>
31+
<textarea class="form-control" data-ng-model="f.data.description"></textarea>
32+
</div>
33+
</div>
34+
</div>

0 commit comments

Comments
 (0)