Dan Brown

Added tags to page display and simplified editing flow

Tags now save with the page content data
...@@ -14,14 +14,17 @@ class PageRepo extends EntityRepo ...@@ -14,14 +14,17 @@ class PageRepo extends EntityRepo
14 { 14 {
15 15
16 protected $pageRevision; 16 protected $pageRevision;
17 + protected $tagRepo;
17 18
18 /** 19 /**
19 * PageRepo constructor. 20 * PageRepo constructor.
20 * @param PageRevision $pageRevision 21 * @param PageRevision $pageRevision
22 + * @param TagRepo $tagRepo
21 */ 23 */
22 - public function __construct(PageRevision $pageRevision) 24 + public function __construct(PageRevision $pageRevision, TagRepo $tagRepo)
23 { 25 {
24 $this->pageRevision = $pageRevision; 26 $this->pageRevision = $pageRevision;
27 + $this->tagRepo = $tagRepo;
25 parent::__construct(); 28 parent::__construct();
26 } 29 }
27 30
...@@ -308,6 +311,11 @@ class PageRepo extends EntityRepo ...@@ -308,6 +311,11 @@ class PageRepo extends EntityRepo
308 $page->slug = $this->findSuitableSlug($input['name'], $book_id, $page->id); 311 $page->slug = $this->findSuitableSlug($input['name'], $book_id, $page->id);
309 } 312 }
310 313
314 + // Save page tags if present
315 + if(isset($input['tags'])) {
316 + $this->tagRepo->saveTagsToEntity($page, $input['tags']);
317 + }
318 +
311 // Update with new details 319 // Update with new details
312 $userId = auth()->user()->id; 320 $userId = auth()->user()->id;
313 $page->fill($input); 321 $page->fill($input);
......
...@@ -122,9 +122,153 @@ ...@@ -122,9 +122,153 @@
122 } 122 }
123 } 123 }
124 124
125 -h1, h2, h3, h4, h5, h6 { 125 +// Attribute form
126 - &:hover a.link-hook { 126 +.floating-toolbox {
127 - opacity: 1; 127 + background-color: #FFF;
128 - transform: translate3d(0, 0, 0); 128 + border: 1px solid #DDD;
129 + right: $-xl*2;
130 + z-index: 99;
131 + width: 48px;
132 + overflow: hidden;
133 + align-items: stretch;
134 + flex-direction: row;
135 + display: flex;
136 + transition: width ease-in-out 180ms;
137 + margin-top: -1px;
138 + &.open {
139 + width: 480px;
140 + }
141 + [toolbox-toggle] i {
142 + transition: transform ease-in-out 180ms;
143 + }
144 + [toolbox-toggle] {
145 + transition: background-color ease-in-out 180ms;
146 + }
147 + &.open [toolbox-toggle] {
148 + background-color: rgba(255, 0, 0, 0.29);
149 + }
150 + &.open [toolbox-toggle] i {
151 + transform: rotate(180deg);
152 + }
153 + > div {
154 + flex: 1;
155 + position: relative;
156 + }
157 + .tabs {
158 + display: block;
159 + border-right: 1px solid #DDD;
160 + width: 54px;
161 + flex: 0;
162 + }
163 + .tabs i {
164 + color: rgba(0, 0, 0, 0.5);
165 + padding: 0;
166 + margin: 0;
167 + }
168 + .tabs > span {
169 + display: block;
170 + cursor: pointer;
171 + padding: $-s $-m;
172 + font-size: 13.5px;
173 + line-height: 1.6;
174 + border-bottom: 1px solid rgba(255, 255, 255, 0.3);
175 + }
176 + &.open .tabs > span.active {
177 + color: #444;
178 + background-color: rgba(0, 0, 0, 0.1);
179 + }
180 + div[tab-content] {
181 + padding-bottom: 45px;
182 + display: flex;
183 + flex: 1;
184 + flex-direction: column;
185 + }
186 + div[tab-content] .padded {
187 + flex: 1;
188 + padding-top: 0;
189 + }
190 + h4 {
191 + font-size: 24px;
192 + margin: $-m 0 0 0;
193 + padding: 0 $-l $-s $-l;
194 + }
195 + .tags input {
196 + max-width: 100%;
197 + width: 100%;
198 + min-width: 50px;
199 + }
200 + .tags td {
201 + padding-right: $-s;
202 + padding-top: $-s;
203 + }
204 + button.pos {
205 + position: absolute;
206 + bottom: 0;
207 + display: block;
208 + width: 100%;
209 + padding: $-s;
210 + height: 45px;
211 + border: 0;
212 + margin: 0;
213 + box-shadow: none;
214 + border-radius: 0;
215 + &:hover{
216 + box-shadow: none;
217 + }
218 + }
219 + .handle {
220 + user-select: none;
221 + cursor: move;
222 + color: #999;
223 + }
224 + form {
225 + display: flex;
226 + flex: 1;
227 + flex-direction: column;
228 + overflow-y: scroll;
229 + }
230 +}
231 +
232 +[tab-content] {
233 + display: none;
234 +}
235 +
236 +.tag-display {
237 + margin: $-xl $-xs;
238 + border: 1px solid #DDD;
239 + min-width: 180px;
240 + max-width: 320px;
241 + opacity: 0.7;
242 + table {
243 + width: 100%;
244 + margin: 0;
245 + padding: 0;
246 + }
247 + span {
248 + color: #666;
249 + margin-left: $-s;
250 + }
251 + .heading {
252 + padding: $-xs $-s;
253 + color: #444;
254 + }
255 + td {
256 + border: 0;
257 + border-bottom: 1px solid #DDD;
258 + padding: $-xs $-s;
259 + color: #444;
260 + }
261 + .tag-value {
262 + color: #888;
263 + }
264 + td i {
265 + color: #888;
266 + }
267 + tr:last-child td {
268 + border-bottom: none;
269 + }
270 + .tag {
271 + padding: $-s;
272 +
129 } 273 }
130 } 274 }
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -207,113 +207,3 @@ $btt-size: 40px; ...@@ -207,113 +207,3 @@ $btt-size: 40px;
207 color: #EEE; 207 color: #EEE;
208 } 208 }
209 } 209 }
210 -
211 -// Attribute form
212 -.floating-toolbox {
213 - background-color: #FFF;
214 - border: 1px solid #DDD;
215 - right: $-xl*2;
216 - z-index: 99;
217 - width: 48px;
218 - overflow: hidden;
219 - align-items: stretch;
220 - flex-direction: row;
221 - display: flex;
222 - transition: width ease-in-out 180ms;
223 - margin-top: -1px;
224 - &.open {
225 - width: 480px;
226 - }
227 - [toolbox-toggle] i {
228 - transition: transform ease-in-out 180ms;
229 - }
230 - [toolbox-toggle] {
231 - transition: background-color ease-in-out 180ms;
232 - }
233 - &.open [toolbox-toggle] {
234 - background-color: rgba(255, 0, 0, 0.29);
235 - }
236 - &.open [toolbox-toggle] i {
237 - transform: rotate(180deg);
238 - }
239 - > div {
240 - flex: 1;
241 - position: relative;
242 - }
243 - .tabs {
244 - display: block;
245 - border-right: 1px solid #DDD;
246 - width: 54px;
247 - flex: 0;
248 - }
249 - .tabs i {
250 - color: rgba(0, 0, 0, 0.5);
251 - padding: 0;
252 - margin: 0;
253 - }
254 - .tabs > span {
255 - display: block;
256 - cursor: pointer;
257 - padding: $-s $-m;
258 - font-size: 13.5px;
259 - line-height: 1.6;
260 - border-bottom: 1px solid rgba(255, 255, 255, 0.3);
261 - }
262 - &.open .tabs > span.active {
263 - color: #444;
264 - background-color: rgba(0, 0, 0, 0.1);
265 - }
266 - div[tab-content] {
267 - padding-bottom: 45px;
268 - display: flex;
269 - flex: 1;
270 - }
271 - div[tab-content] .padded {
272 - flex: 1;
273 - padding-top: 0;
274 - }
275 - h4 {
276 - font-size: 24px;
277 - margin: $-m 0 0 0;
278 - padding: 0 $-l $-s $-l;
279 - }
280 - .tags input {
281 - max-width: 100%;
282 - width: 100%;
283 - min-width: 50px;
284 - }
285 - .tags td {
286 - padding-right: $-s;
287 - padding-top: $-s;
288 - }
289 - button.pos {
290 - position: absolute;
291 - bottom: 0;
292 - display: block;
293 - width: 100%;
294 - padding: $-s;
295 - height: 45px;
296 - border: 0;
297 - margin: 0;
298 - box-shadow: none;
299 - border-radius: 0;
300 - &:hover{
301 - box-shadow: none;
302 - }
303 - }
304 - .handle {
305 - user-select: none;
306 - cursor: move;
307 - color: #999;
308 - }
309 - form {
310 - display: flex;
311 - flex: 1;
312 - flex-direction: column;
313 - overflow-y: scroll;
314 - }
315 -}
316 -
317 -[tab-content] {
318 - display: none;
319 -}
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -14,9 +14,9 @@ ...@@ -14,9 +14,9 @@
14 <input type="hidden" name="_method" value="PUT"> 14 <input type="hidden" name="_method" value="PUT">
15 @endif 15 @endif
16 @include('pages/form', ['model' => $page]) 16 @include('pages/form', ['model' => $page])
17 + @include('pages/form-toolbox')
17 </form> 18 </form>
18 19
19 - @include('pages/form-toolbox')
20 20
21 </div> 21 </div>
22 @include('partials/image-manager', ['imageType' => 'gallery', 'uploaded_to' => $page->id]) 22 @include('partials/image-manager', ['imageType' => 'gallery', 'uploaded_to' => $page->id])
......
...@@ -5,17 +5,16 @@ ...@@ -5,17 +5,16 @@
5 <span tab-button="tags" title="Page Tags" class="active"><i class="zmdi zmdi-tag"></i></span> 5 <span tab-button="tags" title="Page Tags" class="active"><i class="zmdi zmdi-tag"></i></span>
6 </div> 6 </div>
7 <div tab-content="tags" ng-controller="PageTagController" page-id="{{ $page->id or 0 }}"> 7 <div tab-content="tags" ng-controller="PageTagController" page-id="{{ $page->id or 0 }}">
8 - <form ng-submit="saveTags()" >
9 <h4>Page Tags</h4> 8 <h4>Page Tags</h4>
10 <div class="padded tags"> 9 <div class="padded tags">
11 <p class="muted small">Add some tags to better categorise your content. <br> You can assign a value to a tag for more in-depth organisation.</p> 10 <p class="muted small">Add some tags to better categorise your content. <br> You can assign a value to a tag for more in-depth organisation.</p>
12 <table class="no-style" style="width: 100%;"> 11 <table class="no-style" style="width: 100%;">
13 <tbody ui-sortable="sortOptions" ng-model="tags" > 12 <tbody ui-sortable="sortOptions" ng-model="tags" >
14 - <tr ng-repeat="tag in tags"> 13 + <tr ng-repeat="tag in tags track by $index">
15 <td width="20" ><i class="handle zmdi zmdi-menu"></i></td> 14 <td width="20" ><i class="handle zmdi zmdi-menu"></i></td>
16 - <td><input class="outline" type="text" ng-model="tag.name" ng-change="tagChange(tag)" ng-blur="tagBlur(tag)" placeholder="Tag"></td> 15 + <td><input class="outline" ng-attr-name="tags[@{{$index}}][name]" type="text" ng-model="tag.name" ng-change="tagChange(tag)" ng-blur="tagBlur(tag)" placeholder="Tag"></td>
17 - <td><input class="outline" type="text" ng-model="tag.value" ng-change="tagChange(tag)" ng-blur="tagBlur(tag)" placeholder="Tag Value (Optional)"></td> 16 + <td><input class="outline" ng-attr-name="tags[@{{$index}}][value]" type="text" ng-model="tag.value" ng-change="tagChange(tag)" ng-blur="tagBlur(tag)" placeholder="Tag Value (Optional)"></td>
18 - <td width="10" class="text-center text-neg" style="padding: 0;" ng-click="removeTag(tag)"><i class="zmdi zmdi-close"></i></td> 17 + <td width="10" ng-show="tags.length != 1" class="text-center text-neg" style="padding: 0;" ng-click="removeTag(tag)"><i class="zmdi zmdi-close"></i></td>
19 </tr> 18 </tr>
20 </tbody> 19 </tbody>
21 </table> 20 </table>
...@@ -31,7 +30,5 @@ ...@@ -31,7 +30,5 @@
31 </tbody> 30 </tbody>
32 </table> 31 </table>
33 </div> 32 </div>
34 - <button class="button pos" type="submit">Save Tags</button>
35 - </form>
36 </div> 33 </div>
37 </div> 34 </div>
...\ No newline at end of file ...\ No newline at end of file
......
1 <div ng-non-bindable> 1 <div ng-non-bindable>
2 - <h1 id="bkmrk-page-title">{{$page->name}}</h1> 2 +
3 + <h1 id="bkmrk-page-title" class="float left">{{$page->name}}</h1>
4 +
5 + @if(count($page->tags) > 0)
6 + <div class="tag-display float right">
7 + <div class="heading primary-background-light">Page Tags</div>
8 + <table>
9 + @foreach($page->tags as $tag)
10 + <tr class="tag">
11 + <td @if(!$tag->value) colspan="2" @endif> {{ $tag->name }}</td>
12 + @if($tag->value) <td class="tag-value">{{$tag->value}}</td> @endif
13 + </tr>
14 + @endforeach
15 + </table>
16 + </div>
17 + @endif
18 +
19 + <div style="clear:left;"></div>
3 20
4 {!! $page->html !!} 21 {!! $page->html !!}
5 </div> 22 </div>
...\ No newline at end of file ...\ No newline at end of file
......