Skip to content

Commit

Permalink
Issue #185: Migliorie nell`implementazione delle FAQ (testo diviso in…
Browse files Browse the repository at this point in the history
… domanda e risposta)
  • Loading branch information
cironepa committed Jul 24, 2019
1 parent 09a28c2 commit 700acbf
Show file tree
Hide file tree
Showing 20 changed files with 648 additions and 36 deletions.
32 changes: 32 additions & 0 deletions .jhipster/Faq.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"fluentMethods": true,
"relationships": [],
"fields": [
{
"fieldName": "domanda",
"fieldType": "String",
"fieldValidateRules": [
"required"
]
},
{
"fieldName": "risposta",
"fieldType": "String",
"fieldValidateRules": [
"required"
]
},
{
"fieldName": "isReadable",
"fieldType": "Boolean",
"fieldValidateRules": [
"required"
]
}
],
"changelogDate": "20190723085228",
"dto": "no",
"service": "no",
"entityTableName": "faq",
"pagination": "no"
}
38 changes: 28 additions & 10 deletions src/main/java/it/cnr/si/domain/Faq.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import org.hibernate.annotations.CacheConcurrencyStrategy;

import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.*;
import java.io.Serializable;
import java.util.Objects;

Expand All @@ -23,8 +23,12 @@ public class Faq implements Serializable {
private Long id;

@NotNull
@Column(name = "testo", nullable = false)
private String testo;
@Column(name = "domanda", nullable = false)
private String domanda;

@NotNull
@Column(name = "risposta", nullable = false)
private String risposta;

@NotNull
@Column(name = "is_readable", nullable = false)
Expand All @@ -38,17 +42,30 @@ public void setId(Long id) {
this.id = id;
}

public String getTesto() {
return testo;
public String getDomanda() {
return domanda;
}

public Faq domanda(String domanda) {
this.domanda = domanda;
return this;
}

public void setDomanda(String domanda) {
this.domanda = domanda;
}

public String getRisposta() {
return risposta;
}

public Faq testo(String testo) {
this.testo = testo;
public Faq risposta(String risposta) {
this.risposta = risposta;
return this;
}

public void setTesto(String testo) {
this.testo = testo;
public void setRisposta(String risposta) {
this.risposta = risposta;
}

public Boolean isIsReadable() {
Expand Down Expand Up @@ -88,7 +105,8 @@ public int hashCode() {
public String toString() {
return "Faq{" +
"id=" + id +
", testo='" + testo + "'" +
", domanda='" + domanda + "'" +
", risposta='" + risposta + "'" +
", isReadable='" + isReadable + "'" +
'}';
}
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/it/cnr/si/repository/FaqRepository.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package it.cnr.si.repository;

import it.cnr.si.domain.Faq;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import org.springframework.data.jpa.repository.*;

import java.util.List;

Expand All @@ -12,7 +12,7 @@
@SuppressWarnings("unused")
public interface FaqRepository extends JpaRepository<Faq,Long> {


@Query("select faq from Faq faq where faq.isReadable = TRUE")
public List<Faq> getReadableFaq();

}
2 changes: 1 addition & 1 deletion src/main/resources/config/liquibase/cnr/base-faq.csv
Original file line number Diff line number Diff line change
@@ -1 +1 @@
id;testo;is_readable
id;domanda;risposta;is_readable
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@
<column name="id" type="bigint" autoIncrement="${autoIncrement}">
<constraints primaryKey="true" nullable="false"/>
</column>
<column name="testo" type="varchar(255)">
<column name="domanda" type="varchar()">
<constraints nullable="false" />
</column>
<column name="risposta" type="varchar()">
<constraints nullable="false" />
</column>

Expand Down
8 changes: 4 additions & 4 deletions src/main/resources/config/liquibase/cnr/new/faq.csv
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
id;testo;is_readable
1;Prova FAQ 1;TRUE
2;Prova FAQ 2;TRUE
3;Prova FAQ non leggibile;FALSE
id;domanda;risposta;is_readable
1;Domanda 1?;Risposta 1;TRUE
2;Domanda 2?;Risposta 2;TRUE
3;Domanda 3?;Risposta 3;FALSE
28 changes: 28 additions & 0 deletions src/main/webapp/app/entities/faq/faq-delete-dialog.controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
(function() {
'use strict';

angular
.module('sprintApp')
.controller('FaqDeleteController',FaqDeleteController);

FaqDeleteController.$inject = ['$uibModalInstance', 'entity', 'Faq'];

function FaqDeleteController($uibModalInstance, entity, Faq) {
var vm = this;

vm.faq = entity;
vm.clear = clear;
vm.confirmDelete = confirmDelete;

function clear () {
$uibModalInstance.dismiss('cancel');
}

function confirmDelete (id) {
Faq.delete({id: id},
function () {
$uibModalInstance.close(true);
});
}
}
})();
19 changes: 19 additions & 0 deletions src/main/webapp/app/entities/faq/faq-delete-dialog.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<form name="deleteForm" ng-submit="vm.confirmDelete(vm.faq.id)">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true"
ng-click="vm.clear()">&times;</button>
<h4 class="modal-title" translate="entity.delete.title">Confirm delete operation</h4>
</div>
<div class="modal-body">
<jhi-alert-error></jhi-alert-error>
<p translate="sprintApp.faq.delete.question" translate-values="{id: '{{vm.faq.id}}'}">Are you sure you want to delete this Faq?</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal" ng-click="vm.clear()">
<span class="glyphicon glyphicon-ban-circle"></span>&nbsp;<span translate="entity.action.cancel">Cancel</span>
</button>
<button type="submit" ng-disabled="deleteForm.$invalid" class="btn btn-danger">
<span class="glyphicon glyphicon-remove-circle"></span>&nbsp;<span translate="entity.action.delete">Delete</span>
</button>
</div>
</form>
21 changes: 21 additions & 0 deletions src/main/webapp/app/entities/faq/faq-detail.controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
(function() {
'use strict';

angular
.module('sprintApp')
.controller('FaqDetailController', FaqDetailController);

FaqDetailController.$inject = ['$scope', '$rootScope', '$stateParams', 'previousState', 'entity', 'Faq'];

function FaqDetailController($scope, $rootScope, $stateParams, previousState, entity, Faq) {
var vm = this;

vm.faq = entity;
vm.previousState = previousState.name;

var unsubscribe = $rootScope.$on('sprintApp:faqUpdate', function(event, result) {
vm.faq = result;
});
$scope.$on('$destroy', unsubscribe);
}
})();
31 changes: 31 additions & 0 deletions src/main/webapp/app/entities/faq/faq-detail.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@

<div>
<h2><span translate="sprintApp.faq.detail.title">Faq</span> {{vm.faq.id}}</h2>
<hr>
<jhi-alert-error></jhi-alert-error>
<dl class="dl-horizontal jh-entity-details">
<dt><span translate="sprintApp.faq.domanda">Domanda</span></dt>
<dd>
<span>{{vm.faq.domanda}}</span>
</dd>
<dt><span translate="sprintApp.faq.risposta">Risposta</span></dt>
<dd>
<span>{{vm.faq.risposta}}</span>
</dd>
<dt><span translate="sprintApp.faq.isReadable">Is Readable</span></dt>
<dd>
<span>{{vm.faq.isReadable}}</span>
</dd>
</dl>

<button type="submit"
ui-sref="{{ vm.previousState }}"
class="btn btn-info">
<span class="glyphicon glyphicon-arrow-left"></span>&nbsp;<span translate="entity.action.back"> Back</span>
</button>

<button type="button" ui-sref="faq-detail.edit({id:vm.faq.id})" class="btn btn-primary">
<span class="glyphicon glyphicon-pencil"></span>
<span class="hidden-xs hidden-sm" translate="entity.action.edit"> Edit</span>
</button>
</div>
46 changes: 46 additions & 0 deletions src/main/webapp/app/entities/faq/faq-dialog.controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
(function() {
'use strict';

angular
.module('sprintApp')
.controller('FaqDialogController', FaqDialogController);

FaqDialogController.$inject = ['$timeout', '$scope', '$stateParams', '$uibModalInstance', 'entity', 'Faq'];

function FaqDialogController ($timeout, $scope, $stateParams, $uibModalInstance, entity, Faq) {
var vm = this;

vm.faq = entity;
vm.clear = clear;
vm.save = save;

$timeout(function (){
angular.element('.form-group:eq(1)>input').focus();
});

function clear () {
$uibModalInstance.dismiss('cancel');
}

function save () {
vm.isSaving = true;
if (vm.faq.id !== null) {
Faq.update(vm.faq, onSaveSuccess, onSaveError);
} else {
Faq.save(vm.faq, onSaveSuccess, onSaveError);
}
}

function onSaveSuccess (result) {
$scope.$emit('sprintApp:faqUpdate', result);
$uibModalInstance.close(result);
vm.isSaving = false;
}

function onSaveError () {
vm.isSaving = false;
}


}
})();
62 changes: 62 additions & 0 deletions src/main/webapp/app/entities/faq/faq-dialog.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@

<form name="editForm" role="form" novalidate ng-submit="vm.save()" show-validation>

<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true"
ng-click="vm.clear()">&times;</button>
<h4 class="modal-title" id="myFaqLabel" translate="sprintApp.faq.home.createOrEditLabel">Create or edit a Faq</h4>
</div>
<div class="modal-body">
<jhi-alert-error></jhi-alert-error>
<div class="form-group" ng-show="vm.faq.id">
<label for="id" translate="global.field.id">ID</label>
<input type="text" class="form-control" id="id" name="id"
ng-model="vm.faq.id" readonly />
</div>
<div class="form-group">
<label class="control-label" translate="sprintApp.faq.domanda" for="field_domanda">Domanda</label>
<input type="text" class="form-control" name="domanda" id="field_domanda"
ng-model="vm.faq.domanda"
required />
<div ng-show="editForm.domanda.$invalid">
<p class="help-block"
ng-show="editForm.domanda.$error.required" translate="entity.validation.required">
This field is required.
</p>
</div>
</div>
<div class="form-group">
<label class="control-label" translate="sprintApp.faq.risposta" for="field_risposta">Risposta</label>
<input type="text" class="form-control" name="risposta" id="field_risposta"
ng-model="vm.faq.risposta"
required />
<div ng-show="editForm.risposta.$invalid">
<p class="help-block"
ng-show="editForm.risposta.$error.required" translate="entity.validation.required">
This field is required.
</p>
</div>
</div>
<div class="form-group">
<label class="control-label" translate="sprintApp.faq.isReadable" for="field_isReadable">Is Readable</label>
<input type="checkbox" class="form-control" name="isReadable" id="field_isReadable"
ng-model="vm.faq.isReadable"
/>
<div ng-show="editForm.isReadable.$invalid">
<p class="help-block"
ng-show="editForm.isReadable.$error.required" translate="entity.validation.required">
This field is required.
</p>
</div>
</div>

</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal" ng-click="vm.clear()">
<span class="glyphicon glyphicon-ban-circle"></span>&nbsp;<span translate="entity.action.cancel">Cancel</span>
</button>
<button type="submit" ng-disabled="editForm.$invalid || vm.isSaving" class="btn btn-primary">
<span class="glyphicon glyphicon-save"></span>&nbsp;<span translate="entity.action.save">Save</span>
</button>
</div>
</form>
23 changes: 23 additions & 0 deletions src/main/webapp/app/entities/faq/faq.controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
(function() {
'use strict';

angular
.module('sprintApp')
.controller('FaqController', FaqController);

FaqController.$inject = ['$scope', '$state', 'Faq'];

function FaqController ($scope, $state, Faq) {
var vm = this;

vm.faqs = [];

loadAll();

function loadAll() {
Faq.query(function(result) {
vm.faqs = result;
});
}
}
})();
Loading

0 comments on commit 700acbf

Please sign in to comment.