|
@@ -1,93 +1,76 @@
|
|
<div moe wide relative center>
|
|
<div moe wide relative center>
|
|
<a href="" start show>+ Create Survey</a>
|
|
<a href="" start show>+ Create Survey</a>
|
|
-
|
|
|
|
<form url="/api/survey/create" class="mcp-theme-1" right>
|
|
<form url="/api/survey/create" class="mcp-theme-1" right>
|
|
- <input type="hidden" name="entityType" value="Client">
|
|
|
|
- <input type="hidden" name="entityUid" value="{{$patient->uid}}">
|
|
|
|
|
|
+ <input type="hidden" name="entityType" value="Client">
|
|
|
|
+ <input type="hidden" name="entityUid" value="{{ $patient->uid }}">
|
|
<div id="createSurveyForm" v-cloak>
|
|
<div id="createSurveyForm" v-cloak>
|
|
- <div class="form-group">
|
|
|
|
- <label>Survey Template</label>
|
|
|
|
- <select name="internalName" class="form-control">
|
|
|
|
- <option value=""></option>
|
|
|
|
- @foreach ($forms as $form)
|
|
|
|
- <option value="{{ $form }}">{{ formatAsTitle($form) }}</option>
|
|
|
|
- @endforeach
|
|
|
|
- </select>
|
|
|
|
- </div>
|
|
|
|
<div class="form-group">
|
|
<div class="form-group">
|
|
- <label>Title</label>
|
|
|
|
|
|
+ <label class="font-weight-bold">Title</label>
|
|
<input type="text" name="title" class="form-control" />
|
|
<input type="text" name="title" class="form-control" />
|
|
</div>
|
|
</div>
|
|
|
|
+ <div class="form-group">
|
|
|
|
+ <label class="font-weight-bold">Survey Template</label>
|
|
|
|
+ <select name="internalName" class="form-control" v-model="form.internalName" @change="onTemplateChange">
|
|
|
|
+ <option value=""></option>
|
|
|
|
+ @foreach ($forms as $form)
|
|
|
|
+ <option value="{{ $form }}">{{ formatAsTitle($form) }}</option>
|
|
|
|
+ @endforeach
|
|
|
|
+ </select>
|
|
|
|
+ </div>
|
|
|
|
+ <div v-if="previewHtml" class="form-group">
|
|
|
|
+ <label class="font-weight-bold">Template Preview</label>
|
|
|
|
+ <div class="border p-2 d-flex justify-content-center" v-html="previewHtml"></div>
|
|
|
|
+ </div>
|
|
|
|
+
|
|
</div>
|
|
</div>
|
|
<div class="form-group text-nowrap mb-0">
|
|
<div class="form-group text-nowrap mb-0">
|
|
<button class="btn btn-sm btn-primary" submit>Submit</button>
|
|
<button class="btn btn-sm btn-primary" submit>Submit</button>
|
|
<button class="btn btn-sm btn-default border" close>Close</button>
|
|
<button class="btn btn-sm btn-default border" close>Close</button>
|
|
</div>
|
|
</div>
|
|
</form>
|
|
</form>
|
|
- </div>
|
|
|
|
- <script>
|
|
|
|
- (function() {
|
|
|
|
- function init() {
|
|
|
|
- new Vue({
|
|
|
|
- el: '#createSurveyForm',
|
|
|
|
- delimiters: ['@{{ ', ' }}'],
|
|
|
|
- data: {
|
|
|
|
- form: {
|
|
|
|
- entityType: null
|
|
|
|
- },
|
|
|
|
- entityRecords: []
|
|
|
|
|
|
+</div>
|
|
|
|
+<script>
|
|
|
|
+ (function() {
|
|
|
|
+ function init() {
|
|
|
|
+ new Vue({
|
|
|
|
+ el: '#createSurveyForm',
|
|
|
|
+ delimiters: ['@{{ ', ' }}'],
|
|
|
|
+ data: {
|
|
|
|
+ form: {
|
|
|
|
+ internalName: null
|
|
},
|
|
},
|
|
- methods: {
|
|
|
|
- onEntityTypeChange: function() {
|
|
|
|
- var self = this;
|
|
|
|
- if (!self.form.entityType.length) return;
|
|
|
|
- self.$nextTick(function(){
|
|
|
|
- self.initAutoSuggest();
|
|
|
|
- });
|
|
|
|
- },
|
|
|
|
- initAutoSuggest: function() {
|
|
|
|
- var self = this;
|
|
|
|
- var select2 = $("select[name=entityUid]").select2({
|
|
|
|
- placeholder: "Search " + self.form.entityType,
|
|
|
|
- minimumInputLength: 2,
|
|
|
|
- ajax: {
|
|
|
|
- url: '{{ route("patients.view.get-entity-records", $patient) }}',
|
|
|
|
- dataType: 'json',
|
|
|
|
- type: "GET",
|
|
|
|
- quietMillis: 50,
|
|
|
|
- data: function(params) {
|
|
|
|
- return {
|
|
|
|
- term: params.term,
|
|
|
|
- json: true,
|
|
|
|
- type: self.form.entityType,
|
|
|
|
- };
|
|
|
|
- },
|
|
|
|
- processResults: function(data) {
|
|
|
|
- data = data.results || [];
|
|
|
|
- return {
|
|
|
|
- results: $.map(data, function(item) {
|
|
|
|
- return {
|
|
|
|
- text: item.text,
|
|
|
|
- id: item.uid
|
|
|
|
- }
|
|
|
|
- })
|
|
|
|
- };
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
-
|
|
|
|
- },
|
|
|
|
- init: function() {
|
|
|
|
-
|
|
|
|
- },
|
|
|
|
|
|
+ entityRecords: [],
|
|
|
|
+ previewHtml: null
|
|
|
|
+ },
|
|
|
|
+ methods: {
|
|
|
|
+ onTemplateChange: function() {
|
|
|
|
+ var self = this;
|
|
|
|
+ if (!self.form.internalName.length) return;
|
|
|
|
+ self.$nextTick(function() {
|
|
|
|
+ self.loadSelectedTemplate();
|
|
|
|
+ });
|
|
},
|
|
},
|
|
- mounted: function() {
|
|
|
|
- this.init();
|
|
|
|
|
|
+ loadSelectedTemplate: function() {
|
|
|
|
+ var self = this;
|
|
|
|
+ var data = {
|
|
|
|
+ entityType: "Client",
|
|
|
|
+ entityUid: "{{ $patient->uid }}",
|
|
|
|
+ };
|
|
|
|
+ $.get("/survey/template/preview/"+self.form.internalName, data, function(response){
|
|
|
|
+ self.previewHtml = response;
|
|
|
|
+ });
|
|
|
|
+ },
|
|
|
|
+ init: function() {
|
|
|
|
+
|
|
},
|
|
},
|
|
- });
|
|
|
|
|
|
+ },
|
|
|
|
+ mounted: function() {
|
|
|
|
+ this.init();
|
|
|
|
+ },
|
|
|
|
+ });
|
|
|
|
|
|
|
|
|
|
- }
|
|
|
|
- addMCInitializer('createSurveyForm', init, '#createSurveyForm');
|
|
|
|
- })();
|
|
|
|
- </script>
|
|
|
|
|
|
+ }
|
|
|
|
+ addMCInitializer('createSurveyForm', init, '#createSurveyForm');
|
|
|
|
+ })();
|
|
|
|
+</script>
|