Переглянути джерело

CHG Homogénéisation avec la page Collège

julien.legrand 8 роки тому
батько
коміт
b1dfbea891

+ 12 - 12
CD67.FicheCollege.MVC/Controllers/CollegesController.cs

@@ -50,16 +50,16 @@ namespace CD67.FicheCollege.MVC.Controllers
         // plus de détails, voir  http://go.microsoft.com/fwlink/?LinkId=317598.
         [HttpPost]
         [ValidateAntiForgeryToken]
-        public ActionResult Create(College college)
+        public ActionResult Create(Entity.College Contenu)
         {
             if (ModelState.IsValid)
             {
                 CollegeFactory collegeFactory = new CollegeFactory(db);
-                collegeFactory.add(ref college);
+                collegeFactory.add(ref Contenu);
                 return RedirectToAction("Index");
             }
 
-            return View("Edit", GetViewModel(college, Models.ModeAcces.Creation));
+            return View("Edit", GetViewModel(Contenu, Models.ModeAcces.Creation));
         }
 
         // GET: College/Edit/5
@@ -83,15 +83,15 @@ namespace CD67.FicheCollege.MVC.Controllers
         // plus de détails, voir  http://go.microsoft.com/fwlink/?LinkId=317598.
         [HttpPost]
         [ValidateAntiForgeryToken]
-        public ActionResult Edit(College college)
+        public ActionResult Edit(Entity.College Contenu)
         {
             if (ModelState.IsValid)
             {
                 CollegeFactory collegeFactory = new CollegeFactory(db);
-                collegeFactory.update(ref college);
-                return RedirectToAction("Details", new { Id = college.Id });
+                collegeFactory.update(ref Contenu);
+                return RedirectToAction("Details", new { Id = Contenu.Id });
             }
-            return View(GetViewModel(college, Models.ModeAcces.Modification));
+            return View(GetViewModel(Contenu, Models.ModeAcces.Modification));
         }
 
         // GET: College/Delete/5
@@ -121,7 +121,7 @@ namespace CD67.FicheCollege.MVC.Controllers
             return RedirectToAction("Index");
         }
 
-        private Models.CollegeViewModel GetViewModel(Entity.College college, Models.ModeAcces Acces)
+        private Models.CollegeViewModel GetViewModel(Entity.College entity, Models.ModeAcces Acces)
         {
             Dictionary<string, SelectList> listes = new Dictionary<string, SelectList>();
 
@@ -129,15 +129,15 @@ namespace CD67.FicheCollege.MVC.Controllers
             if (Acces == Models.ModeAcces.Creation || Acces == Models.ModeAcces.Modification)
             {
                 TypeCollegeFactory typeCollegeFactory = new TypeCollegeFactory(db);
-                SelectList listeTypeCollege = new SelectList(typeCollegeFactory.getAll("Ordre"), "Id", "Libelle", college.TypeCollege_Id);
+                SelectList listeTypeCollege = new SelectList(typeCollegeFactory.getAll("Ordre"), "Id", "Libelle", entity.TypeCollege_Id);
                 listes.Add("TypeCollege_Id", listeTypeCollege);
             }
 
             return new Models.CollegeViewModel()
             {
-                College_Id = college.Id,
-                College_Libelle = college.Libelle,
-                Contenu = college,
+                College_Id = entity.Id,
+                College_Libelle = entity.Libelle,
+                Contenu = entity,
                 Acces = Acces,
                 Listes = listes
             };

+ 30 - 23
CD67.FicheCollege.MVC/Views/Colleges/Details.cshtml

@@ -4,10 +4,18 @@
 @{
     ViewBag.Title = "Details";
     Layout = "~/Views/Shared/_Layout.cshtml";
-    College college = Model.Contenu as College;
+    College contenu = Model.Contenu as College;
 }
 
-<h1>@college.Libelle</h1>
+<!-- Menu de niveau 2 -->
+<div>
+    <ul id="menu-l2">
+        <li id="li-menu-l2"><a id="a-li-menu-l2-active" class="btn-sm" href="@Url.Action("Details", "Colleges", new { Id = Model.College_Id })">Général</a></li>
+        <li id="li-menu-l2"><a id="a-li-menu-l2" class="btn-sm" href="@Url.Action("Details", "Identites", new { Id = Model.College_Id })/">Identité</a></li>
+    </ul>
+</div>
+
+<h1>@Model.College_Libelle</h1>
 @if(Model.Acces==ModeAcces.Suppression) {
     <h2 class="text-danger">Voulez-vous vraiment supprimer cet élément?</h2>
     <p class="text-danger">
@@ -17,63 +25,63 @@
 
 <fieldset>
     <legend>
-        Détails du collège
+        Informations générales
         @if (Model.Acces == ModeAcces.Lecture)
         {
             <div class="pull-right">
-                @Html.ActionLink("Supprimer", "Delete", "Colleges", new { Id = college.Id }, new { @class = "btn btn-danger" })
-                @Html.ActionLink("Modifier", "Edit", "Colleges", new { Id = college.Id }, new { @class = "btn btn-default" })
+                @Html.ActionLink("Supprimer", "Delete", "Colleges", new { Id = Model.College_Id }, new { @class = "btn btn-danger" })
+                @Html.ActionLink("Modifier", "Edit", "Colleges", new { Id = Model.College_Id }, new { @class = "btn btn-default" })
             </div>
         }
     </legend>
     <dl class="dl-horizontal">
         <dt>
-            @Html.DisplayNameFor(model => college.TypeCollege.Libelle)
+            @Html.DisplayNameFor(model => contenu.TypeCollege.Libelle)
         </dt>
 
         <dd>
-            @Html.DisplayFor(model => college.TypeCollege.Libelle)
+            @Html.DisplayFor(model => contenu.TypeCollege.Libelle)
         </dd>
 
         <dt>
-            @Html.DisplayNameFor(model => college.Adresse)
+            @Html.DisplayNameFor(model => contenu.Adresse)
         </dt>
 
         <dd>
-            @Html.DisplayFor(model => college.AdresseComplete)
+            @Html.DisplayFor(model => contenu.AdresseComplete)
         </dd>
 
         <dt>
-            @Html.DisplayNameFor(model => college.Tel)
+            @Html.DisplayNameFor(model => contenu.Tel)
         </dt>
 
         <dd>
-            @Html.DisplayFor(model => college.Tel)
+            @Html.DisplayFor(model => contenu.Tel)
         </dd>
 
         <dt>
-            @Html.DisplayNameFor(model => college.Fax)
+            @Html.DisplayNameFor(model => contenu.Fax)
         </dt>
 
         <dd>
-            @Html.DisplayFor(model => college.Fax)
+            @Html.DisplayFor(model => contenu.Fax)
         </dd>
 
         <dt>
-            @Html.DisplayNameFor(model => college.Email)
+            @Html.DisplayNameFor(model => contenu.Email)
         </dt>
 
         <dd>
-            @Html.DisplayFor(model => college.Email)
+            @Html.DisplayFor(model => contenu.Email)
         </dd>
 
         <dt>
-            @Html.DisplayNameFor(model => college.Commune)
+            @Html.DisplayNameFor(model => contenu.Commune)
         </dt>
 
         <dd>
-            @if (college.Commune != null)
-        {
+            @if (contenu.Commune != null)
+            {
                 <div class="col-sm-8 col-md-4">
                     <div class="panel panel-default">
                         <div class="panel-heading clearfix">
@@ -83,11 +91,10 @@
                             </h4>
                         </div>
                         <div class="panel-body" style="text-align: center;">
-                            <span style="white-space: pre-line;">
-                                <b>@college.Commune</b>
-                                Canton : @college.Canton
-                                TAD : @college.TAD
-                                CDC : @college.CDC
+                            <span style="white-space: pre-line;"><b>@contenu.Commune</b>
+                                Canton : @contenu.Canton
+                                TAD : @contenu.TAD
+                                CDC : @contenu.CDC
                             </span>
                         </div>
                     </div>

+ 103 - 99
CD67.FicheCollege.MVC/Views/Colleges/Edit.cshtml

@@ -4,133 +4,137 @@
 @{
     ViewBag.Title = "Ajout";
     Layout = "~/Views/Shared/_Layout.cshtml";
-    College college = Model.Contenu as College;
+    College contenu = Model.Contenu as College;
 }
 
-<h2>@Model.Acces.ToString()</h2>
-
+<h1>@Model.College_Libelle</h1>
 
 @using (Html.BeginForm())
 {
     @Html.AntiForgeryToken()
 
-    <div class="form-horizontal">
-        <h4>Collège</h4>
-        <hr />
-        @Html.ValidationSummary(true, "", new { @class = "text-danger" })
-
-        @if (Model.Acces == ModeAcces.Modification)
-        {
-            @Html.HiddenFor(model => college.Id)
-        }
-        <div class="form-group">
-            @Html.LabelFor(model => college.Id, htmlAttributes: new { @class = "control-label col-md-2" })
-            <div class="col-md-10">
-                @if (Model.Acces == ModeAcces.Modification)
-                {
-                    @Html.EditorFor(model => college.Id, new { htmlAttributes = new { @class = "form-control", @disabled = true } })
-                }
-                else
-                {
-                    @Html.EditorFor(model => college.Id, new { htmlAttributes = new { @class = "form-control" } })
-                }
-                @Html.ValidationMessageFor(model => college.Id, "", new { @class = "text-danger" })
+    <fieldset>
+        <legend>
+            Informations générales - @Model.Acces.ToString()
+        </legend>
+        <div class="form-horizontal">
+            <h4>Collège</h4>
+            <hr />
+            @Html.ValidationSummary(true, "", new { @class = "text-danger" })
+
+            @if (Model.Acces == ModeAcces.Modification)
+            {
+                @Html.HiddenFor(model => contenu.Id)
+            }
+            <div class="form-group">
+                @Html.LabelFor(model => contenu.Id, htmlAttributes: new { @class = "control-label col-md-2" })
+                <div class="col-md-10">
+                    @if (Model.Acces == ModeAcces.Modification)
+                    {
+                        @Html.EditorFor(model => contenu.Id, new { htmlAttributes = new { @class = "form-control", @disabled = true } })
+                    }
+                    else
+                    {
+                        @Html.EditorFor(model => contenu.Id, new { htmlAttributes = new { @class = "form-control" } })
+                    }
+                    @Html.ValidationMessageFor(model => contenu.Id, "", new { @class = "text-danger" })
+                </div>
             </div>
-        </div>
 
-        <div class="form-group">
-            @Html.LabelFor(model => college.Libelle, htmlAttributes: new { @class = "control-label col-md-2" })
-            <div class="col-md-10">
-                @Html.EditorFor(model => college.Libelle, new { htmlAttributes = new { @class = "form-control" } })
-                @Html.ValidationMessageFor(model => college.Libelle, "", new { @class = "text-danger" })
+            <div class="form-group">
+                @Html.LabelFor(model => contenu.Libelle, htmlAttributes: new { @class = "control-label col-md-2" })
+                <div class="col-md-10">
+                    @Html.EditorFor(model => contenu.Libelle, new { htmlAttributes = new { @class = "form-control" } })
+                    @Html.ValidationMessageFor(model => contenu.Libelle, "", new { @class = "text-danger" })
+                </div>
             </div>
-        </div>
 
-        <div class="form-group">
-            @Html.LabelFor(model => college.TypeCollege_Id, htmlAttributes: new { @class = "control-label col-md-2" })
-            <div class="col-md-10">
-                @Html.DropDownListFor(model => college.TypeCollege_Id, Model.Listes["TypeCollege_Id"], htmlAttributes: new { @class = "form-control" })
-                @Html.ValidationMessageFor(model => college.TypeCollege_Id, "", new { @class = "text-danger" })
+            <div class="form-group">
+                @Html.LabelFor(model => contenu.TypeCollege_Id, htmlAttributes: new { @class = "control-label col-md-2" })
+                <div class="col-md-10">
+                    @Html.DropDownListFor(model => contenu.TypeCollege_Id, Model.Listes["TypeCollege_Id"], htmlAttributes: new { @class = "form-control" })
+                    @Html.ValidationMessageFor(model => contenu.TypeCollege_Id, "", new { @class = "text-danger" })
+                </div>
             </div>
-        </div>
 
-        <div class="form-group">
-            @Html.LabelFor(model => college.Adresse, htmlAttributes: new { @class = "control-label col-md-2" })
-            <div class="col-md-10">
-                @Html.EditorFor(model => college.Adresse, new { htmlAttributes = new { @class = "form-control" } })
-                @Html.ValidationMessageFor(model => college.Adresse, "", new { @class = "text-danger" })
+            <div class="form-group">
+                @Html.LabelFor(model => contenu.Adresse, htmlAttributes: new { @class = "control-label col-md-2" })
+                <div class="col-md-10">
+                    @Html.EditorFor(model => contenu.Adresse, new { htmlAttributes = new { @class = "form-control" } })
+                    @Html.ValidationMessageFor(model => contenu.Adresse, "", new { @class = "text-danger" })
+                </div>
             </div>
-        </div>
 
-        @Html.HiddenFor(model => college.Code_Postal, new { data_picker = "commune.code_postal" })
-        @Html.HiddenFor(model => college.Commune_Insee, new { data_picker = "commune.insee" })
-        @Html.HiddenFor(model => college.Commune, new { data_picker = "commune.nom" })
-        @Html.HiddenFor(model => college.Canton, new { data_picker = "commune.canton" })
-        @Html.HiddenFor(model => college.Territoire_Id, new { data_picker = "commune.code_tad" })
-        @Html.HiddenFor(model => college.TAD, new { data_picker = "commune.tad" })
-        @Html.HiddenFor(model => college.CDC, new { data_picker = "commune.cdc" })
-        <div class="form-group">
-            @Html.LabelFor(model => college.Commune, htmlAttributes: new { @class = "control-label col-md-2 required" })
-            <div class="col-md-4">
-                <a class='modal-window' href="http://referentiel.bas-rhin.fr/picker/cd67/com67/" title="Selection commune (nouvelle fenetre)">Sélectionner une commune</a>
-                <br />
-                <div class="panel panel-default" id="Commune_Panel" name="Commune_Panel" style="@if (college.Commune_Insee == null) { <text>display: none;</text> }">
-                    <div class="panel-heading clearfix">
-                        <h4 class="panel-title pull-left" style="padding-top: 7.5px;">
-                            <i class="fa fa-map-marker color1" aria-hidden="true"></i>
-                            Localisation (commune)
-                        </h4>
-                        <div class="pull-right">
-                            <span class="glyphicon glyphicon-trash removeItem btn btn-danger btn-sm" aria-hidden="true" data-type="commune"></span>
+            @Html.HiddenFor(model => contenu.Code_Postal, new { data_picker = "commune.code_postal" })
+            @Html.HiddenFor(model => contenu.Commune_Insee, new { data_picker = "commune.insee" })
+            @Html.HiddenFor(model => contenu.Commune, new { data_picker = "commune.nom" })
+            @Html.HiddenFor(model => contenu.Canton, new { data_picker = "commune.canton" })
+            @Html.HiddenFor(model => contenu.Territoire_Id, new { data_picker = "commune.code_tad" })
+            @Html.HiddenFor(model => contenu.TAD, new { data_picker = "commune.tad" })
+            @Html.HiddenFor(model => contenu.CDC, new { data_picker = "commune.cdc" })
+            <div class="form-group">
+                @Html.LabelFor(model => contenu.Commune, htmlAttributes: new { @class = "control-label col-md-2 required" })
+                <div class="col-md-4">
+                    <a class='modal-window' href="http://referentiel.bas-rhin.fr/picker/cd67/com67/" title="Selection commune (nouvelle fenetre)">Sélectionner une commune</a>
+                    <br />
+                    <div class="panel panel-default" id="Commune_Panel" name="Commune_Panel" style="@if (contenu.Commune_Insee == null) { <text>display: none;</text> }">
+                        <div class="panel-heading clearfix">
+                            <h4 class="panel-title pull-left" style="padding-top: 7.5px;">
+                                <i class="fa fa-map-marker color1" aria-hidden="true"></i>
+                                Localisation (commune)
+                            </h4>
+                            <div class="pull-right">
+                                <span class="glyphicon glyphicon-trash removeItem btn btn-danger btn-sm" aria-hidden="true" data-type="commune"></span>
+                            </div>
+                        </div>
+                        <div class="panel-body" style="text-align: center;">
+                            <span>
+                                <b><span data-picker="commune.nom">@contenu.Commune</span ></b >
+                                <br />Canton : <span data-picker="commune.canton">@contenu.Canton</span >
+                                <br />TAD : <span data-picker="commune.tad">@contenu.TAD</span >
+                                <br />CDC : <span data-picker="commune.cdc">@contenu.CDC</span >
+                            </span>
                         </div>
                     </div>
-                    <div class="panel-body" style="text-align: center;">
-                        <span>
-                            <b><span data-picker="commune.nom">@college.Commune</span ></b >
-                            <br />Canton : <span data-picker="commune.canton">@college.Canton</span >
-                            <br />TAD : <span data-picker="commune.tad">@college.TAD</span >
-                            <br />CDC : <span data-picker="commune.cdc">@college.CDC</span >
-                        </span>
-                    </div>
+                    @Html.ValidationMessageFor(model => contenu.Commune, "", new { @class = "text-danger" })
                 </div>
-                @Html.ValidationMessageFor(model => college.Commune, "", new { @class = "text-danger" })
             </div>
-        </div>
 
-        <div class="form-group">
-            @Html.LabelFor(model => college.Tel, htmlAttributes: new { @class = "control-label col-md-2" })
-            <div class="col-md-10">
-                @Html.EditorFor(model => college.Tel, new { htmlAttributes = new { @class = "form-control" } })
-                @Html.ValidationMessageFor(model => college.Tel, "", new { @class = "text-danger" })
+            <div class="form-group">
+                @Html.LabelFor(model => contenu.Tel, htmlAttributes: new { @class = "control-label col-md-2" })
+                <div class="col-md-10">
+                    @Html.EditorFor(model => contenu.Tel, new { htmlAttributes = new { @class = "form-control" } })
+                    @Html.ValidationMessageFor(model => contenu.Tel, "", new { @class = "text-danger" })
+                </div>
             </div>
-        </div>
 
-        <div class="form-group">
-            @Html.LabelFor(model => college.Fax, htmlAttributes: new { @class = "control-label col-md-2" })
-            <div class="col-md-10">
-                @Html.EditorFor(model => college.Fax, new { htmlAttributes = new { @class = "form-control" } })
-                @Html.ValidationMessageFor(model => college.Fax, "", new { @class = "text-danger" })
+            <div class="form-group">
+                @Html.LabelFor(model => contenu.Fax, htmlAttributes: new { @class = "control-label col-md-2" })
+                <div class="col-md-10">
+                    @Html.EditorFor(model => contenu.Fax, new { htmlAttributes = new { @class = "form-control" } })
+                    @Html.ValidationMessageFor(model => contenu.Fax, "", new { @class = "text-danger" })
+                </div>
             </div>
-        </div>
 
-        <div class="form-group">
-            @Html.LabelFor(model => college.Email, htmlAttributes: new { @class = "control-label col-md-2" })
-            <div class="col-md-10">
-                @Html.EditorFor(model => college.Email, new { htmlAttributes = new { @class = "form-control" } })
-                @Html.ValidationMessageFor(model => college.Email, "", new { @class = "text-danger" })
+            <div class="form-group">
+                @Html.LabelFor(model => contenu.Email, htmlAttributes: new { @class = "control-label col-md-2" })
+                <div class="col-md-10">
+                    @Html.EditorFor(model => contenu.Email, new { htmlAttributes = new { @class = "form-control" } })
+                    @Html.ValidationMessageFor(model => contenu.Email, "", new { @class = "text-danger" })
+                </div>
             </div>
-        </div>
 
-        <div class="form-group">
-            <div class="col-md-offset-2 col-md-10">
-                <input type="submit" value="@Model.Acces.EnumDisplayNameFor(MvcHtmlHelpers.DisplayValue.Prompt)" class="btn btn-default" /> |
-                @if (Model.Acces == ModeAcces.Creation)
-                { @Html.ActionLink("Annuler", "Index") }
-                else
-                { @Html.ActionLink("Annuler", "Details", new { Id = Model.College_Id }) }
+            <div class="form-group">
+                <div class="col-md-offset-2 col-md-10">
+                    <input type="submit" value="@Model.Acces.EnumDisplayNameFor(MvcHtmlHelpers.DisplayValue.Prompt)" class="btn btn-default" /> |
+                    @if (Model.Acces == ModeAcces.Creation)
+                    { @Html.ActionLink("Annuler", "Index") }
+                    else
+                    { @Html.ActionLink("Annuler", "Details", new { Id = Model.College_Id }) }
+                </div>
             </div>
         </div>
-    </div>
+    </fieldset>
 }
 
 @section Scripts {