%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /var/www/html/conference/resources/views/admin/articles/
Upload File :
Create Path :
Current File : //var/www/html/conference/resources/views/admin/articles/show.blade.php

@extends('layouts.app')

@section('content')
    <div class="container">
        <div class="row">
            <div class="col-md-12">
                <form class="{{$errors->count() > 0 ? 'was-validated' : ''}}"
                      method="POST"
                      autocomplete="off"
                      enctype="multipart/form-data"
                      @if($article->id)
                      action="{{ route('admin.articles.update', ['article' => $article->id]) }}"
                      @else
                      action="{{ route('admin.articles.store') }}"
                      @endif
                      novalidate>
                    {{ csrf_field() }}
                    <div class="form-group row">
                        <div class="col-md-12">
                            <h2>Article</h2>
                        </div>
                    </div>
                    <div class="form-group row">
                        <div class="col-md-12">
                            <label class="form-control-label" for="title">Title</label>
                            <input id="title" type="text"
                                   class="form-control"
                                   name="title" placeholder="Title" required
                                   value="{{ $article->title }}" autofocus>
                            @if ($errors->has('title'))
                                <div class="invalid-feedback">
                                    <strong>{{ $errors->first('title') }}</strong>
                                </div>
                            @endif
                        </div>
                    </div>
                    <div class="form-group row">
                        <div class="col-md-12">
                            <label class="form-control-label" for="description">Description</label>
                            <textarea name="description" id="description" rows="10"
                                      placeholder="Description"
                                      class="form-control"
                                      required>{{$article->description}}</textarea>
                            @if ($errors->has('description'))
                                <div class="invalid-feedback">
                                    <strong>{{ $errors->first('description') }}</strong>
                                </div>
                            @endif
                        </div>
                    </div>
                    <div class="form-group row">
                        <div class="col-md-12">
                            <label class="form-control-label" for="session">Session</label>
                            <input id="session" type="number"
                                   class="form-control"
                                   name="session" placeholder="Session" required
                                   value="{{ $article->session }}" min="1" max="9">
                            @if ($errors->has('session'))
                                <div class="invalid-feedback">
                                    <strong>{{ $errors->first('session') }}</strong>
                                </div>
                            @endif
                        </div>
                    </div>
                    <div class="form-group row">
                        <div class="col-md-12">
                            <label class="form-control-label" for="authors">Authors</label>
                            <input type="text" class="form-control" id="authors" name="authors"
                                   data-source="{{$article->authors}}" placeholder="Author"
                                   data-is-new="{{($article->id)}}" data-role="tagsinput">
                        </div>
                    </div>
                    <div class="form-group row">
                        <div class="col-md-12">
                            <label class="form-control-label" for="keywords">Keywords</label>
                            <input type="text" class="form-control" id="keywords" name="keywords"
                                   data-source="{{$article->keyWords}}" placeholder="Keyword"
                                   data-is-new="{{($article->id)}}" data-role="tagsinput">
                        </div>
                    </div>
                    <div class="form-group row">
                        <div class="col-md-12">
                            <label class="form-control-label" for="category">Category</label>
                            <select class="form-control"
                                    id="category" name="category" required>
                                <option value="">Category</option>
                                @foreach($categories as $category)
                                    <option value="{{$category['slug']}}"
                                            {{$category['slug'] == $article->category ? 'selected' : ''}}>
                                        {{$category['description']}}
                                    </option>
                                @endforeach
                            </select>
                            @if ($errors->has('category'))
                                <div class="invalid-feedback">
                                    <strong>{{ $errors->first('category') }}</strong>
                                </div>
                            @endif
                        </div>
                    </div>
                    @if(!$article->id)
                        <div class="form-group row">
                            <div class="col-md-12">
                                <input class="form-control" type="file" name="pdf_file" id="pdf_file"
                                       accept="application/pdf" required>
                                @if ($errors->has('pdf_file'))
                                    <div class="invalid-feedback">
                                        <strong>{{ $errors->first('pdf_file') }}</strong>
                                    </div>
                                @endif
                            </div>
                        </div>
                    @endif
                    <div class="form-group row">
                        <div class="col-md-8 col-md-offset-3">
                            <button type="submit" class="btn btn-primary">
                                Save
                            </button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
@endsection
@section('script')
    <script src="{{asset('js/libs/tagsinput.js')}}"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/typeahead.js/0.11.1/typeahead.bundle.min.js"></script>
    <script>
      var element = $('#authors');
      var articleId = element.attr('data-is-new');
      var isNew = !articleId;
      var dataSource = JSON.parse(element.attr('data-source'));
      var skills = new Bloodhound({
        datumTokenizer: Bloodhound.tokenizers.obj.whitespace('id'),
        queryTokenizer: Bloodhound.tokenizers.whitespace,
        remote: {
          url: '/api/authors?term=%QUERY%',
          wildcard: '%QUERY%'
        }
      });
      skills.initialize();
      element.tagsinput({
        itemValue: 'id',
        itemText: 'fullname',
        maxChars: 30,
        trimValue: true,
        allowDuplicates: false,
        freeInput: false,
        focusClass: 'form-control',
        tagClass: function (item) {
          if (item.display)
            return 'badge badge-' + item.display;
          else
            return 'badge badge-primary';
        },
        onTagExists: function (item, $tag) {
          $tag.hide().fadeIn();
        },
        typeaheadjs: [
          {
            hint: false,
            highlight: true
          },
          {
            name: 'authors',
            itemValue: 'id',
            displayKey: 'fullname',
            source: skills.ttAdapter(),
            templates: {
              empty: [
                '<ul class="list-group"><li class="list-group-item">Nothing found.</li></ul>'
              ],
              header: [
                '<ul class="list-group">'
              ],
              suggestion: function (data) {
                return '<li class="list-group-item">' + data.fullname + '</li>'
              }
            }
          }]
      });
      dataSource.forEach(function (value) {
        element.tagsinput('add', value)
      });
      element.on('beforeItemAdd', function (event, item) {
        if (!isNew) {
          $.ajax({
            type: 'GET',
            url: '/api/articles/' + articleId + '/attachAuthor/' + event.item.id,
            dataType: 'json',
            success: function () {
              toastr.success('Author successfully associated');
            },
            error: function () {
              //TODO: remove author from input
              toastr.error('Unexpected error occurred during author association');
            }
          });
        }
      });
      element.on('beforeItemRemove', function (event) {
        if (!isNew) {
          $.ajax({
            type: 'GET',
            url: '/api/articles/' + articleId + '/detachAuthor/' + event.item.id,
            dataType: 'json',
            success: function () {
              toastr.success('Author successfully disassociated');
            },
            error: function () {
              //TODO: add again author on input
              toastr.error('Unexpected error occurred during author disassociation');
            }
          });
        }
      });
    </script>
    <script>
      var element = $('#keywords');
      var articleId = element.attr('data-is-new');
      var isNew = !articleId;
      var dataSource = JSON.parse(element.attr('data-source'));
      var skills = new Bloodhound({
        datumTokenizer: Bloodhound.tokenizers.obj.whitespace('id'),
        queryTokenizer: Bloodhound.tokenizers.whitespace,
        remote: {
          url: '/api/keywords?term=%QUERY%',
          wildcard: '%QUERY%'
        }
      });
      skills.initialize();
      element.tagsinput({
        itemValue: 'tag',
        itemText: 'tag',
        maxChars: 30,
        trimValue: true,
        allowDuplicates: false,
        freeInput: true,
        focusClass: 'form-control',
        tagClass: function (item) {
          if (item.display)
            return 'badge badge-' + item.display;
          else
            return 'badge badge-primary';
        },
        onTagExists: function (item, $tag) {
          $tag.hide().fadeIn();
        },
        typeaheadjs: [
          {
            hint: false,
            highlight: true
          },
          {
            name: 'keywords',
            itemValue: 'tag',
            displayKey: 'tag',
            source: skills.ttAdapter(),
            templates: {
              header: [
                '<ul class="list-group">'
              ],
              suggestion: function (data) {
                return '<li class="list-group-item">' + data.tag + '</li>'
              }
            }
          }]
      });
      dataSource.forEach(function (value) {
        element.tagsinput('add', value)
      });
      element.on('beforeItemAdd', function (event) {
        if (typeof event.item === 'string') {
          event.cancel = true;
          element.tagsinput('add', {tag: event.item})
        } else if (!isNew) {
          $.ajax({
            type: 'GET',
            url: '/api/articles/' + articleId + '/attachKeyword/' + event.item.tag,
            dataType: 'json',
            error: function () {
              //TODO: remove author from input
              toastr.error('Unexpected error occurred during author association');
            }
          });
        }
      });
      element.on('beforeItemRemove', function (event) {
        if (!isNew) {
          $.ajax({
            type: 'GET',
            url: '/api/articles/' + articleId + '/detachKeyword/' + event.item.id,
            dataType: 'json',
            error: function () {
              //TODO: add again author on input
              toastr.error('Unexpected error occurred during author disassociation');
            }
          });
        }
      });
    </script>
@endsection

Zerion Mini Shell 1.0