Merge branch 'dev'
This commit is contained in:
commit
0b4ed3c772
19 changed files with 115 additions and 37 deletions
|
@ -14,5 +14,13 @@ module.exports = {
|
||||||
},
|
},
|
||||||
rules: {
|
rules: {
|
||||||
'prettier/prettier': 'error'
|
'prettier/prettier': 'error'
|
||||||
|
},
|
||||||
|
overrides: [
|
||||||
|
{
|
||||||
|
files: ['config/webpack/*.js'],
|
||||||
|
env: {
|
||||||
|
node: true
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
};
|
};
|
||||||
|
|
|
@ -38,4 +38,15 @@
|
||||||
.messagerie-explanation {
|
.messagerie-explanation {
|
||||||
margin-bottom: $default-padding * 2;
|
margin-bottom: $default-padding * 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.latest-message-section {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
max-width: 700px;
|
||||||
|
margin-bottom: $default-padding * 2;
|
||||||
|
|
||||||
|
.button.send {
|
||||||
|
align-self: flex-end;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,10 @@
|
||||||
background: #FFFFFF;
|
background: #FFFFFF;
|
||||||
border-radius: 3px;
|
border-radius: 3px;
|
||||||
|
|
||||||
|
&.inverted-background {
|
||||||
|
background: $light-grey;
|
||||||
|
}
|
||||||
|
|
||||||
.person-icon {
|
.person-icon {
|
||||||
margin-right: $default-spacer;
|
margin-right: $default-spacer;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
.status-overview {
|
.status-overview {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
|
margin-bottom: $default-padding * 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
.status-timeline {
|
.status-timeline {
|
||||||
|
|
|
@ -1,10 +1,18 @@
|
||||||
module CommentaireHelper
|
module CommentaireHelper
|
||||||
def commentaire_is_from_me_class(commentaire, email)
|
def commentaire_is_from_me_class(commentaire, connected_user)
|
||||||
if commentaire.email == email
|
if commentaire_is_from_me(commentaire, connected_user)
|
||||||
"from-me"
|
"from-me"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def commentaire_answer_action(commentaire, connected_user)
|
||||||
|
if commentaire_is_from_me(commentaire, connected_user)
|
||||||
|
"Envoyer un message à l’instructeur"
|
||||||
|
else
|
||||||
|
"Répondre dans la messagerie"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def commentaire_is_from_guest(commentaire)
|
def commentaire_is_from_guest(commentaire)
|
||||||
commentaire.dossier.invites.map(&:email).include?(commentaire.email)
|
commentaire.dossier.invites.map(&:email).include?(commentaire.email)
|
||||||
end
|
end
|
||||||
|
@ -14,4 +22,10 @@ module CommentaireHelper
|
||||||
template = is_current_year ? :message_date : :message_date_with_year
|
template = is_current_year ? :message_date : :message_date_with_year
|
||||||
I18n.l(commentaire.created_at.localtime, format: template)
|
I18n.l(commentaire.created_at.localtime, format: template)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def commentaire_is_from_me(commentaire, connected_user)
|
||||||
|
commentaire.email == connected_user.email
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,13 +1,9 @@
|
||||||
|
import '../shared/polyfills';
|
||||||
import Turbolinks from 'turbolinks';
|
import Turbolinks from 'turbolinks';
|
||||||
import Rails from 'rails-ujs';
|
import Rails from 'rails-ujs';
|
||||||
import ActiveStorage from '../shared/activestorage/ujs';
|
import ActiveStorage from '../shared/activestorage/ujs';
|
||||||
import jQuery from 'jquery';
|
import jQuery from 'jquery';
|
||||||
|
|
||||||
// Include runtime-polyfills for older browsers.
|
|
||||||
// Due to .babelrc's 'useBuiltIns', only polyfills actually
|
|
||||||
// required by the browsers we support will be included.
|
|
||||||
import 'babel-polyfill';
|
|
||||||
|
|
||||||
import '../shared/sentry';
|
import '../shared/sentry';
|
||||||
import '../shared/rails-ujs-fix';
|
import '../shared/rails-ujs-fix';
|
||||||
import '../shared/safari-11-file-xhr-workaround';
|
import '../shared/safari-11-file-xhr-workaround';
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import '../shared/polyfills';
|
||||||
import Turbolinks from 'turbolinks';
|
import Turbolinks from 'turbolinks';
|
||||||
import Rails from 'rails-ujs';
|
import Rails from 'rails-ujs';
|
||||||
import ActiveStorage from '../shared/activestorage/ujs';
|
import ActiveStorage from '../shared/activestorage/ujs';
|
||||||
|
@ -5,11 +6,6 @@ import Chartkick from 'chartkick';
|
||||||
import Highcharts from 'highcharts';
|
import Highcharts from 'highcharts';
|
||||||
import jQuery from 'jquery';
|
import jQuery from 'jquery';
|
||||||
|
|
||||||
// Include runtime-polyfills for older browsers.
|
|
||||||
// Due to .babelrc's 'useBuiltIns', only polyfills actually
|
|
||||||
// required by the browsers we support will be included.
|
|
||||||
import 'babel-polyfill';
|
|
||||||
|
|
||||||
import '../shared/sentry';
|
import '../shared/sentry';
|
||||||
import '../shared/rails-ujs-fix';
|
import '../shared/rails-ujs-fix';
|
||||||
import '../shared/safari-11-file-xhr-workaround';
|
import '../shared/safari-11-file-xhr-workaround';
|
||||||
|
|
5
app/javascript/shared/polyfills.js
Normal file
5
app/javascript/shared/polyfills.js
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
// Include runtime-polyfills for older browsers.
|
||||||
|
// Due to .babelrc's 'useBuiltIns', only polyfills actually
|
||||||
|
// required by the browsers we support will be included.
|
||||||
|
import 'babel-polyfill';
|
||||||
|
import 'dom4';
|
|
@ -5,3 +5,13 @@
|
||||||
|
|
||||||
.container
|
.container
|
||||||
= render partial: 'new_user/dossiers/show/status_overview', locals: { dossier: @dossier }
|
= render partial: 'new_user/dossiers/show/status_overview', locals: { dossier: @dossier }
|
||||||
|
|
||||||
|
- latest_message = @dossier.commentaires.last
|
||||||
|
- if latest_message.present?
|
||||||
|
.latest-message-section
|
||||||
|
%h3.tab-title Dernier message
|
||||||
|
|
||||||
|
.message.inverted-background
|
||||||
|
= render partial: "shared/dossiers/messages/message", locals: { commentaire: latest_message, connected_user: current_user, messagerie_seen_at: nil }
|
||||||
|
|
||||||
|
= link_to commentaire_answer_action(latest_message, current_user), messagerie_dossier_url(@dossier, anchor: 'new_commentaire'), class: 'button send'
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
.messagerie.container
|
.messagerie.container
|
||||||
%ul.messages-list
|
%ul.messages-list
|
||||||
- dossier.commentaires.each do |commentaire|
|
- dossier.commentaires.each do |commentaire|
|
||||||
%li.message{ class: commentaire_is_from_me_class(commentaire, connected_user.email) }
|
%li.message{ class: commentaire_is_from_me_class(commentaire, connected_user) }
|
||||||
= render partial: "shared/dossiers/messages/message", locals: { commentaire: commentaire, connected_user: connected_user, messagerie_seen_at: messagerie_seen_at }
|
= render partial: "shared/dossiers/messages/message", locals: { commentaire: commentaire, connected_user: connected_user, messagerie_seen_at: messagerie_seen_at }
|
||||||
|
|
||||||
= render partial: "shared/dossiers/messages/form", locals: { commentaire: new_commentaire, form_url: form_url }
|
= render partial: "shared/dossiers/messages/form", locals: { commentaire: new_commentaire, form_url: form_url }
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
process.env.NODE_ENV = process.env.NODE_ENV || 'development'
|
process.env.NODE_ENV = process.env.NODE_ENV || 'development';
|
||||||
|
|
||||||
const environment = require('./environment')
|
const environment = require('./environment');
|
||||||
|
|
||||||
module.exports = environment.toWebpackConfig()
|
module.exports = environment.toWebpackConfig();
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
const { environment } = require('@rails/webpacker')
|
const { environment } = require('@rails/webpacker');
|
||||||
|
|
||||||
// By default don't transpile JS files in ./node_modules – except for some specific modules.
|
// By default don't transpile JS files in ./node_modules – except for some specific modules.
|
||||||
const babelLoader = environment.loaders.get('babel');
|
const babelLoader = environment.loaders.get('babel');
|
||||||
|
@ -6,8 +6,12 @@ babelLoader.exclude = function(modulePath) {
|
||||||
let forcedModules = [
|
let forcedModules = [
|
||||||
'activestorage' // ActiveStorage uses 'class', which is not supported by IE 11 and older Safari version
|
'activestorage' // ActiveStorage uses 'class', which is not supported by IE 11 and older Safari version
|
||||||
];
|
];
|
||||||
return modulePath.includes('node_modules')
|
return (
|
||||||
&& forcedModules.every(forcedModule => !modulePath.includes('node_modules/' + forcedModule));
|
modulePath.includes('node_modules') &&
|
||||||
}
|
forcedModules.every(
|
||||||
|
forcedModule => !modulePath.includes('node_modules/' + forcedModule)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
module.exports = environment
|
module.exports = environment;
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
process.env.NODE_ENV = process.env.NODE_ENV || 'production'
|
process.env.NODE_ENV = process.env.NODE_ENV || 'production';
|
||||||
|
|
||||||
const environment = require('./environment')
|
const environment = require('./environment');
|
||||||
|
|
||||||
// https://github.com/rails/webpacker/issues/1235
|
// https://github.com/rails/webpacker/issues/1235
|
||||||
environment.config.optimization.minimizer[0].options.uglifyOptions.ecma = 5; // for IE 11 support
|
environment.config.optimization.minimizer[0].options.uglifyOptions.ecma = 5; // for IE 11 support
|
||||||
environment.config.optimization.minimizer[0].options.uglifyOptions.safari10 = true;
|
environment.config.optimization.minimizer[0].options.uglifyOptions.safari10 = true;
|
||||||
|
|
||||||
module.exports = environment.toWebpackConfig()
|
module.exports = environment.toWebpackConfig();
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
process.env.NODE_ENV = process.env.NODE_ENV || 'development'
|
process.env.NODE_ENV = process.env.NODE_ENV || 'development';
|
||||||
|
|
||||||
const environment = require('./environment')
|
const environment = require('./environment');
|
||||||
|
|
||||||
module.exports = environment.toWebpackConfig()
|
module.exports = environment.toWebpackConfig();
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
"autocomplete.js": "^0.31.0",
|
"autocomplete.js": "^0.31.0",
|
||||||
"chartkick": "^2.3.6",
|
"chartkick": "^2.3.6",
|
||||||
"debounce": "^1.2.0",
|
"debounce": "^1.2.0",
|
||||||
|
"dom4": "^2.1.3",
|
||||||
"highcharts": "^6.1.1",
|
"highcharts": "^6.1.1",
|
||||||
"jquery": "^3.3.1",
|
"jquery": "^3.3.1",
|
||||||
"leaflet": "^1.3.1",
|
"leaflet": "^1.3.1",
|
||||||
|
@ -21,7 +22,7 @@
|
||||||
"webpack-dev-server": "^3.1.4"
|
"webpack-dev-server": "^3.1.4"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"lint:js": "eslint ./app/javascript"
|
"lint:js": "eslint ./app/javascript ./config/webpack"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": "6.* || 8.* || >= 10.*"
|
"node": "6.* || 8.* || >= 10.*"
|
||||||
|
|
|
@ -4,7 +4,7 @@ describe 'Dossier details:' do
|
||||||
tdcs = [create(:type_de_champ, libelle: 'texte obligatoire')]
|
tdcs = [create(:type_de_champ, libelle: 'texte obligatoire')]
|
||||||
create(:procedure, :published, :for_individual, types_de_champ: tdcs)
|
create(:procedure, :published, :for_individual, types_de_champ: tdcs)
|
||||||
end
|
end
|
||||||
let(:dossier) { create(:dossier, :en_construction, :for_individual, user: user, procedure: simple_procedure) }
|
let(:dossier) { create(:dossier, :en_construction, :for_individual, :with_commentaires, user: user, procedure: simple_procedure) }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
Flipflop::FeatureSet.current.test!.switch!(:new_dossier_details, true)
|
Flipflop::FeatureSet.current.test!.switch!(:new_dossier_details, true)
|
||||||
|
@ -16,6 +16,7 @@ describe 'Dossier details:' do
|
||||||
expect(page).to have_current_path(dossier_path(dossier))
|
expect(page).to have_current_path(dossier_path(dossier))
|
||||||
expect(page).to have_content(dossier.id)
|
expect(page).to have_content(dossier.id)
|
||||||
expect(page).to have_selector('.status-explanation')
|
expect(page).to have_selector('.status-explanation')
|
||||||
|
expect(page).to have_text(dossier.commentaires.last.body)
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario 'the user can see and edit dossier before instruction' do
|
scenario 'the user can see and edit dossier before instruction' do
|
||||||
|
|
|
@ -1,24 +1,36 @@
|
||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe CommentaireHelper, type: :helper do
|
RSpec.describe CommentaireHelper, type: :helper do
|
||||||
describe ".commentaire_is_from_me_class" do
|
|
||||||
let(:commentaire) { create(:commentaire, email: "michel@pref.fr") }
|
let(:commentaire) { create(:commentaire, email: "michel@pref.fr") }
|
||||||
|
|
||||||
|
describe ".commentaire_is_from_me_class" do
|
||||||
subject { commentaire_is_from_me_class(commentaire, me) }
|
subject { commentaire_is_from_me_class(commentaire, me) }
|
||||||
|
|
||||||
context "when commentaire is from me" do
|
context "when commentaire is from me" do
|
||||||
let(:me) { "michel@pref.fr" }
|
let(:me) { User.new(email: "michel@pref.fr") }
|
||||||
|
|
||||||
it { is_expected.to eq("from-me") }
|
it { is_expected.to eq("from-me") }
|
||||||
end
|
end
|
||||||
|
|
||||||
context "when commentaire is not from me" do
|
context "when commentaire is not from me" do
|
||||||
let(:me) { "roger@usager.fr" }
|
let(:me) { User.new(email: "roger@usager.fr") }
|
||||||
|
|
||||||
it { is_expected.to eq nil }
|
it { is_expected.to eq nil }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe '.commentaire_answer_action' do
|
||||||
|
subject { commentaire_answer_action(commentaire, me) }
|
||||||
|
|
||||||
|
context "when commentaire is from me" do
|
||||||
|
let(:me) { User.new(email: "michel@pref.fr") }
|
||||||
|
it { is_expected.to include('Envoyer') }
|
||||||
|
end
|
||||||
|
|
||||||
|
context "when commentaire is not from me" do
|
||||||
|
let(:me) { User.new(email: "roger@usager.fr") }
|
||||||
|
it { is_expected.to include('Répondre') }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe '.commentaire_is_from_guest' do
|
describe '.commentaire_is_from_guest' do
|
||||||
let(:dossier) { create(:dossier) }
|
let(:dossier) { create(:dossier) }
|
||||||
let!(:guest) { create(:invite_user, dossier: dossier) }
|
let!(:guest) { create(:invite_user, dossier: dossier) }
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
|
|
||||||
describe 'new_user/dossiers/show.html.haml', type: :view do
|
describe 'new_user/dossiers/show.html.haml', type: :view do
|
||||||
let(:dossier) { create(:dossier, :en_construction, procedure: create(:procedure)) }
|
let(:dossier) { create(:dossier, :en_construction) }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
sign_in dossier.user
|
sign_in dossier.user
|
||||||
|
@ -14,4 +14,15 @@ describe 'new_user/dossiers/show.html.haml', type: :view do
|
||||||
expect(rendered).to have_text("Dossier nº #{dossier.id}")
|
expect(rendered).to have_text("Dossier nº #{dossier.id}")
|
||||||
expect(rendered).to have_selector('.status-overview')
|
expect(rendered).to have_selector('.status-overview')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'with messages' do
|
||||||
|
let(:first_message) { create(:commentaire, body: 'Premier message') }
|
||||||
|
let(:last_message) { create(:commentaire, body: 'Second message') }
|
||||||
|
let(:dossier) { create(:dossier, :en_construction, commentaires: [first_message, last_message]) }
|
||||||
|
|
||||||
|
it 'displays the last message' do
|
||||||
|
expect(rendered).not_to have_text(first_message.body)
|
||||||
|
expect(rendered).to have_text(last_message.body)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -2319,6 +2319,10 @@ doctrine@^2.1.0:
|
||||||
dependencies:
|
dependencies:
|
||||||
esutils "^2.0.2"
|
esutils "^2.0.2"
|
||||||
|
|
||||||
|
dom4@^2.1.3:
|
||||||
|
version "2.1.3"
|
||||||
|
resolved "https://registry.yarnpkg.com/dom4/-/dom4-2.1.3.tgz#f71808fe1f141e4da4ebc43ad5ddb3dd521f2767"
|
||||||
|
|
||||||
domain-browser@^1.1.1:
|
domain-browser@^1.1.1:
|
||||||
version "1.2.0"
|
version "1.2.0"
|
||||||
resolved "https://registry.yarnpkg.com/domain-browser/-/domain-browser-1.2.0.tgz#3d31f50191a6749dd1375a7f522e823d42e54eda"
|
resolved "https://registry.yarnpkg.com/domain-browser/-/domain-browser-1.2.0.tgz#3d31f50191a6749dd1375a7f522e823d42e54eda"
|
||||||
|
|
Loading…
Reference in a new issue