Receipt create. Part 2

This commit is contained in:
alexey
2025-02-22 23:28:36 +03:00
parent 6527af5005
commit d608f73772
11 changed files with 356 additions and 24 deletions

View File

@@ -7,6 +7,7 @@
<title><%= @page_name %></title>
<link rel="stylesheet" href="/assets/bootstrap/css/bootstrap.min.css">
<link rel="stylesheet" href="/assets/css/Footer-Dark-icons.css">
<link rel="stylesheet" href="/js/jquery.dropdown.min.css">
<script src="/js/jquery-3.7.1.min.js"></script>
</head>
@@ -20,6 +21,10 @@
</div>
<div class="container">
<div class="hstack gap-3">
<span class="p-1">
<a href="/">главная</a>
</span>
<span>|</span>
<span class="p-1">
<a href="/repos">git-репозитории</a>
</span>

View File

@@ -9,6 +9,7 @@
toolbar: "search, go_to_line, fullscreen, |, undo, redo, |, select_font,|, highlight, reset_highlight, word_wrap, |, syntax_selection"
});
</script>
<script src="/js/jquery.dropdown.min.js"></script>
<% unless @error_data.nil? %>
<div class="container">
<div class="alert alert-warning alert-dismissible fade show" role="alert"><span><%= @error_data %></span><button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Закрыть"></button></div>
@@ -18,19 +19,38 @@
<form action="/rcpcreate" method="post">
<div class="mb-3">
<label for="filepath" class="form-label">Имя рецепта (англиские буквы, _, .)</label>
<input type="email" class="form-control" id="filepath" name="filepath">
<input type="text" class="form-control" id="filepath" name="filepath" value="<%= @old_filepath %>">
</div>
<div class="mb-3">
<label for="description" class="form-label">Описание рецепта сборки</label>
<textarea class="form-control" id="description" name="description" rows="3"></textarea>
<textarea class="form-control" id="description" name="description" rows="3"><%= @old_description %></textarea>
</div>
<div class="mb-3">
<label for="codedata" class="form-label">Код</label>
<textarea class="form-control" id="codedata" name="codedata" rows="3"></textarea>
<textarea class="form-control" id="codedata" name="codedata" rows="3"><%= @old_codedata %></textarea>
</div>
<div class="mb-3">
<label for="gitlist" class="form-label">git проекты, использующие рецепт</label>
<div class="gitlist">
<select class="form-control" id="gitlst" name="gitlst[]" multiple>
<% @repo_data.each do |item| %>
<% if !@old_gitlst.nil? && @old_gitlst.include?(item[:id].to_s) %>
<option value="<%= item[:id] %>" selected><%= item[:reponame] %></option>
<% else %>
<option value="<%= item[:id] %>"><%= item[:reponame] %></option>
<% end %>
<% end %>
</select>
</div>
</div>
<div class="mb-3 text-center">
<button type="submit" class="btn btn-primary">Сохранить</button>
</div>
</form>
</div>
<script>
$('.gitlist').dropdown({
searchNoData: '<li style="color:#ddd">Нет данных</li>',
});
</script>
<%= erb :footer %>

125
views/rcpedit.erb Normal file
View File

@@ -0,0 +1,125 @@
<%= erb :header %>
<script src="/js/edit_area_full.js"></script>
<script language="javascript" type="text/javascript">
editAreaLoader.init({
id: "codedata",
syntax: "bash",
start_highlight: true,
language: "ru",
toolbar: "search, go_to_line, fullscreen, |, undo, redo, |, select_font,|, highlight, reset_highlight, word_wrap, |, syntax_selection"
});
</script>
<script src="/js/jquery.dropdown.min.js"></script>
<% unless @error_data.nil? %>
<div class="container">
<div class="alert alert-warning alert-dismissible fade show" role="alert"><span><%= @error_data %></span><button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Закрыть"></button></div>
</div>
<% end %>
<div class="container">
<form action="/recips/<%= ERB::Util.url_encode(@rcp_id) %>" method="post">
<div class="mb-3">
<label for="filepath" class="form-label">Имя рецепта (англиские буквы, _, .)</label>
<input type="text" class="form-control" id="filepath" name="filepath" value="<%= @old_filepath %>">
</div>
<div class="mb-3">
<label for="description" class="form-label">Описание рецепта сборки</label>
<textarea class="form-control" id="description" name="description" rows="3"><%= @old_description %></textarea>
</div>
<div class="mb-3">
<label for="codedata" class="form-label">Код</label>
<textarea class="form-control" id="codedata" name="codedata" rows="3"><%= @old_codedata %></textarea>
</div>
<div class="mb-3">
<label for="gitlist" class="form-label">git проекты, использующие рецепт</label>
<div class="gitlist">
<select class="form-control" id="gitlst" name="gitlst[]" multiple>
<% @repo_data.each do |item| %>
<% if !@old_gitlst.nil? && @old_gitlst.include?(item[:id].to_s) %>
<option value="<%= item[:id] %>" selected><%= item[:reponame] %></option>
<% else %>
<option value="<%= item[:id] %>"><%= item[:reponame] %></option>
<% end %>
<% end %>
</select>
</div>
</div>
<div class="mb-3 text-center">
<button type="submit" class="btn btn-primary">Сохранить</button>
<button type="submit" class="btn btn-danger" id="delete">Удалить</button>
<div id="winkeeper"></div>
</div>
</form>
</div>
<script>
$('.gitlist').dropdown({
searchNoData: '<li style="color:#ddd">Нет данных</li>',
});
</script>
<script src="/js/jquery-confirm.min.js"></script>
<script>
$("#delete").confirm({
title: 'Подтвердите удаление репозитория!',
content: '' +
'<div class="container">' +
'<form action="/rcpdelete/<%= ERB::Util.url_encode(@rcp_id) %>" class="formName" method="post">' +
'<div class="text-danger mx-auto p-2">' +
'<label>Введите название удаляемого рецепта</label>' +
'<input type="text" class="frmchk form-control" required name="rcpnamedup"/>' +
'<input type="hidden" class="frmchk form-control" id="rcphid" name="rcphid" value="<%= @rcp_name %>"/>' +
'</div>' +
'</form>' +
'</div>',
container: '#winkeeper',
theme: 'bootstrap',
buttons: {
formSubmit: {
text: 'Удалить',
titleClass: 'text-danger mx-auto p-2',
btnClass: 'btn btn-danger',
action: function () {
var correct_name = this.$content.find("#rcphid").val();
var name = this.$content.find('.frmchk').val();
if(!name){
$.alert({
title: 'Предупреждение!',
content: 'Название не может быть пустым',
container: '#winkeeper',
theme: 'bootstrap',
buttons: {
ok: {
text: 'Хорошо',
btnClass: 'btn btn-danger',
}
}
});
return false;
}
if (name != correct_name){
$.alert({
title: 'Предупреждение!',
content: 'Название задано неверно',
container: '#winkeeper',
theme: 'bootstrap',
buttons: {
ok: {
text: 'Хорошо',
btnClass: 'btn btn-danger',
}
}
});
return false;
}
this.$content.find('form').submit();
return true;
}
},
cancel: {
text: 'Отменить',
btnClass: 'btn btn-primary',
action: function () {
//close
}},
},
});
</script>
<%= erb :footer %>

View File

@@ -1,16 +1,19 @@
<%= erb :header %>
<div class="container py-4 py-xl-5">
<div class="row mb-5">
<div class="row pb-5">
<div class="col-md-8 col-xl-6 text-center mx-auto">
<h2>Доступные рецепты</h2>
<p class="w-lg-50">Страница управления рецептами</p>
<div>
<div class="px-3"><a href="/rcpcreate"><svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" fill="currentColor" viewBox="0 0 16 16" class="bi bi-plus-circle text-primary" style="font-size: 29px;">
<path d="M8 15A7 7 0 1 1 8 1a7 7 0 0 1 0 14zm0 1A8 8 0 1 0 8 0a8 8 0 0 0 0 16z"></path>
<path d="M8 4a.5.5 0 0 1 .5.5v3h3a.5.5 0 0 1 0 1h-3v3a.5.5 0 0 1-1 0v-3h-3a.5.5 0 0 1 0-1h3v-3A.5.5 0 0 1 8 4z"></path>
</svg>&nbsp;Добавить рецепт</a></div>
<div class="px-3"><a href="/rcpcreate">
<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" fill="currentColor" viewBox="0 0 16 16" class="bi bi-plus-circle text-primary" style="font-size: 29px;">
<path d="M8 15A7 7 0 1 1 8 1a7 7 0 0 1 0 14zm0 1A8 8 0 1 0 8 0a8 8 0 0 0 0 16z"></path>
<path d="M8 4a.5.5 0 0 1 .5.5v3h3a.5.5 0 0 1 0 1h-3v3a.5.5 0 0 1-1 0v-3h-3a.5.5 0 0 1 0-1h3v-3A.5.5 0 0 1 8 4z"></path>
</svg>&nbsp;Добавить рецепт</a>
</div>
</div>
</div>
</div>
<div class="container text-center">
<div class="row gy-3">
<% @rcp_data.each do |item| %>