Form calls

This commit is contained in:
KennyTV 2020-07-14 20:23:17 +02:00
parent 09fef55e49
commit 95b9b2aa76
No known key found for this signature in database
GPG Key ID: 6BE3B555EBC5982B
10 changed files with 91 additions and 78 deletions

View File

@ -1,6 +1,8 @@
<#import "/spring.ftl" as spring />
<#import "*/utils/hangar.ftlh" as hangar />
<#import "*/projects/channels/helper/popoverColorPicker.ftlh" as popoverColorPicker />
<#import "*/utils/form.ftlh" as form>
<#import "*/utils/csrf.ftlh" as csrf>
@import ore.OreConfig
@import views.html.helper.{CSRF, form}
@ -16,13 +18,13 @@
</button>
<h4 class="modal-title"></h4>
</div>
@form(action = routes.Application.showHome()) {
@CSRF.formField
<@form.form action=routes.getRouteUrl("showHome") method="GET">
<@csrf.formField />
<div class="modal-body">
<div class="form-inline">
<label for="channel-input"><@spring.message "channel.name" /></label>
<input class="form-control channel-input" name="channel-input" type="text" value=""
maxlength="@config.ore.channels.maxNameLen"/>
maxlength="${config.ore.channels.maxNameLen}"/>
<input type="hidden" name="channel-color-input" class="channel-color-input" value="" />
<a href="#">
<span class="color-picker" data-toggle="popover" data-placement="right" data-trigger="hover">
@ -51,7 +53,7 @@
</button>
<input type="submit" value="" class="btn btn-primary" disabled />
</div>
}
</@form.form>
</div>
</div>
</div>

View File

@ -1,6 +1,8 @@
<#import "/spring.ftl" as spring />
<#import "*/utils/hangar.ftlh" as hangar />
<#import "*/projects/channels/helper/modalManage.ftlh" as modalManage />
<#import "*/utils/form.ftlh" as form>
<#import "*/utils/csrf.ftlh" as csrf>
@import controllers.sugar.Requests.OreRequest
@import models.viewhelper.ProjectData
@ -58,12 +60,11 @@
id="channel-delete-${channel.id}" data-channel-delete="safe-delete"
data-channel-id="${channel.id}">
@form(action = routes.getRouteUrl("channels.delete",
p.project.ownerName, p.project.slug, channel.name),
Symbol("id") -> s"form-delete-${channel.id}",
Symbol("class") -> "form-channel-delete") {
@CSRF.formField
}
<@form.form method="POST" action=routes.getRouteUrl("channels.delete", p.project.ownerName, p.project.slug, channel.name)
id="form-delete-${channel.id}"
class="form-channel-delete">
<@csrf.formField />
</@form.form>
</#if>
Delete
</div>

View File

@ -1,5 +1,7 @@
<#import "/spring.ftl" as spring />
<#import "*/utils/hangar.ftlh" as hangar />
<#import "*/utils/form.ftlh" as form>
<#import "*/utils/csrf.ftlh" as csrf>
@import controllers.sugar.Requests.OreRequest
@import models.viewhelper.{ProjectData, ScopedProjectData}
@ -210,14 +212,13 @@
</div>
</#if>
@form(action = routes.getRouteUrl("projects.save", p.project.ownerName, p.project.slug), Symbol("id") -> "save",
Symbol("class") -> "pull-right") {
@CSRF.formField
<@form.form action=routes.getRouteUrl("projects.save", p.project.ownerName, p.project.slug) method="POST" id="save" class="pull-right">
<@csrf.formField />
<input type="hidden" id="update-icon" name="update-icon" value="false" />
<button type="submit" name="save" class="btn btn-success btn-spinner" data-icon="fa-check">
<i class="fas fa-check"></i> Save changes
</button>
}
</@form.form>
</div>
</div>
</div>
@ -249,13 +250,13 @@
</div>
<div class="modal-footer">
<div class="form-inline">
@form(action = routes.getRouteUrl("projects.rename", p.project.ownerName, p.project.slug), Symbol("id") -> "rename") {
@CSRF.formField
<button type="button" class="btn btn-default" data-dismiss="modal">
<@spring.message "channel.edit.close" />
</button>
<input type="submit" name="rename" value="<@spring.message "project.rename" />" class="btn btn-warning">
}
<@form.form action=routes.getRouteUrl("projects.rename", p.project.ownerName, p.project.slug) method="POST" id="rename">
<@csrf.formField />
<button type="button" class="btn btn-default" data-dismiss="modal">
<@spring.message "channel.edit.close" />
</button>
<input type="submit" name="rename" value="<@spring.message "project.rename" />" class="btn btn-warning">
</@form.form>
</div>
</div>
</div>
@ -271,19 +272,19 @@
</button>
<h4 class="modal-title" id="label-delete"><@spring.message "project.delete.title" /></h4>
</div>
@form(action = routes.getRouteUrl("projects.softDelete", p.project.ownerName, p.project.slug)) {
<@form.form action=routes.getRouteUrl("projects.softDelete", p.project.ownerName, p.project.slug) method="POST">
<div class="modal-body">
<@spring.message "project.delete.info" />
<br>
<textarea name="comment" class="textarea-delete-comment form-control" rows="3"></textarea>
<br>
<div class="alert alert-warning">
<@spring.message "project.delete.info.uniqueid", p.project.name />
<@spring.messageArgs "project.delete.info.uniqueid", p.project.name />
</div>
</div>
<div class="modal-footer">
<div class="form-inline">
@CSRF.formField
<@csrf.formField />
<button type="button" class="btn btn-default" data-dismiss="modal">
<@spring.message "channel.edit.close" />
</button>
@ -291,7 +292,7 @@
value="<@spring.message "general.delete" />" class="btn btn-danger">
</div>
</div>
}
</@form.form>
</div>
</div>

View File

@ -1,6 +1,8 @@
<#import "/spring.ftl" as spring />
<#import "*/utils/hangar.ftlh" as hangar />
<#import "*/layout/base.ftlh" as base />
<#import "*/utils/form.ftlh" as form>
<#import "*/utils/csrf.ftlh" as csrf>
@import controllers.sugar.Requests.OreRequest
@import models.querymodels.ViewTag
@ -148,32 +150,31 @@
}
</#if>
@form(action = routes.getRouteUrl("versions.upload", ownerName, projectSlug),
Symbol("enctype") -> "multipart/form-data", Symbol("id") -> "form-upload") {
@CSRF.formField
<@form.form action=routes.getRouteUrl("versions.upload", ownerName, projectSlug) method="POST"
enctype="multipart/form-data" id="form-upload">
<@csrf.formField />
<label class="btn btn-default pull-left" for="pluginFile">
<input id="pluginFile" name="pluginFile" type="file" style="display: none;">
<@spring.message "version.create.selectFile" />
</label>
${projects.helper.alertFile()}
}
</@form.form>
<#if pending??>
@* Ready to go! *@
@defining(pending.get) { version: PendingVersion =>
@form(action = routes.getRouteUrl("versions.publish",
ownerName, projectSlug, version.versionString),
Symbol("id") -> "form-publish", Symbol("class") -> "pull-right") {
@CSRF.formField
<@form.form method="POST" action=routes.getRouteUrl("versions.publish", ownerName, projectSlug, version.versionString)
id="form-publish" class="pull-right">
<@csrf.formField />
<input type="hidden" class="channel-color-input" name="channel-color-input"
value="@config.defaultChannelColor.hex" />
value="${config.defaultChannelColor.hex}" />
<div>
<input type="submit" name="create" value="<@spring.message "version.create.publish" />"
class="btn btn-primary" />
</div>
}
</@form.form>
}
</#if>

View File

@ -1,5 +1,7 @@
<#import "/spring.ftl" as spring />
<#import "*/utils/hangar.ftlh" as hangar />
<#import "*/utils/form.ftlh" as form>
<#import "*/utils/csrf.ftlh" as csrf>
@import controllers.sugar.Requests.OreRequest
@import models.viewhelper.{ScopedProjectData, VersionData}
@ -69,13 +71,12 @@
<div>
<#if !v.isRecommended && sp.perms(Permission.EditVersion) && v.v.visibility != Visibility.SoftDelete>
@form(action = versionRoutes.setRecommended(
v.p.project.ownerName, v.p.project.slug, v.v.versionString), Symbol("class") -> "form-inline") {
@CSRF.formField
<@form.form method="POST" action=routes.getRouteUrl("versions.setRecommended", v.p.project.ownerName, v.p.project.slug, v.v.versionString) class="form-inline">
<@csrf.formField />
<button type="submit" class="btn btn-info">
<i class="fas fa-gem"></i> Set recommended
</button>
}
</@form.form>
</#if>
<#if request.headerData.globalPerm(Permission.Reviewer)>
@ -233,21 +234,21 @@
</button>
<h4 class="modal-title" id="label-delete"><@spring.message "version.delete.title" /></h4>
</div>
@form(action = versionRoutes.softDelete(v.p.project.ownerName, v.p.project.slug, v.v.versionString)) {
<@form.form method="POST" action=routes.getRouteUrl("versions.softDelete", v.p.project.ownerName, v.p.project.slug, v.v.versionString)>
<div class="modal-body">
<@spring.message "version.delete.info" />
<textarea name="comment" class="textarea-delete-comment form-control" rows="3"></textarea>
</div>
<div class="modal-footer">
<div class="form-inline">
@CSRF.formField
<@csrf.formField />
<button type="button" class="btn btn-default" data-dismiss="modal">
<@spring.message "channel.edit.close" />
</button>
<input type="submit" name="delete" value="<@spring.message "general.delete" />" class="btn btn-danger">
</div>
</div>
}
</@form.form>
</div>
</div>
</div>
@ -264,20 +265,20 @@
</button>
<h4 class="modal-title" id="label-delete"><@spring.message "general.restore" /></h4>
</div>
@form(action = versionRoutes.restore(v.p.project.ownerName, v.p.project.slug, v.v.versionString)) {
<@form.form method="POST" action=routes.getRouteUrl("versions.restore", v.p.project.ownerName, v.p.project.slug, v.v.versionString)>
<div class="modal-body">
<textarea name="comment" class="textarea-delete-comment form-control" rows="3"></textarea>
</div>
<div class="modal-footer">
<div class="form-inline">
@CSRF.formField
<@csrf.formField />
<button type="button" class="btn btn-default" data-dismiss="modal">
<@spring.message "channel.edit.close" />
</button>
<input type="submit" name="delete" value="<@spring.message "general.restore" />" class="btn btn-success">
</div>
</div>
}
</@form.form>
</div>
</div>
</div>
@ -292,20 +293,20 @@
</button>
<h4 class="modal-title" id="label-delete"><@spring.message "general.harddelete" /></h4>
</div>
@form(action = versionRoutes.delete(v.p.project.ownerName, v.p.project.slug, v.v.versionString)) {
<@form.form method="POST" action=routes.getRouteUrl("versions.delete", v.p.project.ownerName, v.p.project.slug, v.v.versionString)>
<div class="modal-body">
<textarea name="comment" class="textarea-delete-comment form-control" rows="3"></textarea>
</div>
<div class="modal-footer">
<div class="form-inline">
@CSRF.formField
<@csrf.formField />
<button type="button" class="btn btn-default" data-dismiss="modal">
<@spring.message "channel.edit.close" />
</button>
<input type="submit" name="delete" value="<@spring.message "general.harddelete" />" class="btn btn-danger">
</div>
</div>
}
</@form.form>
</div>
</div>
</div>

View File

@ -140,9 +140,11 @@ TODO: this is a layout, should we move/rename it?
</button>
<h4 class="modal-title" id="label-flag">Flag project</h4>
</div>
@form(action = Projects.flag(
p.project.ownerName, p.project.slug)) {
@CSRF.formField
<#import "*/utils/form.ftlh" as form>
<#-- todo: Projects.flag -->
<@form.form action=Projects.flag( p.project.ownerName, p.project.slug)>
<#import "*/utils/csrf.ftlh" as csrf>
<@csrf.formField />
<div class="modal-body">
<ul class="list-group list-flags">
<#list FlagReason.values.indices as i>
@ -165,7 +167,7 @@ TODO: this is a layout, should we move/rename it?
</button>
<button type="submit" class="btn btn-primary">Flag</button>
</div>
}
</@form.form>
</div>
</div>
</div>

View File

@ -1,5 +1,7 @@
<#import "/spring.ftl" as spring />
<#import "*/utils/hangar.ftlh" as hangar />
<#import "*/utils/form.ftlh" as form>
<#import "*/utils/csrf.ftlh" as csrf>
@import ore.OreConfig
@import ore.models.user.role.UserRoleModel
@ -49,14 +51,15 @@
</div>
<div class="modal-body"><@spring.message "project.removeMember.confirm" /></div>
<div class="modal-footer">
@form(action = removeCall, Symbol("class") -> "form-inline") {
@CSRF.formField
<#-- todo: removeCall, gotten from settings template -->
<@form.form action=removeCall method="POST" class="form-inline">
<@csrf.formField />
<input type="hidden" name="username" />
<button type="button" class="btn btn-default" data-dismiss="modal">
<@spring.message "general.close" />
</button>
<button type="submit" class="btn btn-danger"><@spring.message "general.remove" /></button>
}
</@form.form>
</div>
</div>
</div>
@ -81,13 +84,14 @@
</#if>
<#if saveCall??>
@form(action = saveCall, Symbol("id") -> "save") {
@CSRF.formField
<#-- todo: saveCall, gotten from settings template -->
<@form.form action=saveCall method="POST" id="save">
<@csrf.formField />
<button class="btn-members-save btn btn-default btn-panel btn-xs" data-toggle="tooltip"
data-placement="top" data-title="<@spring.message "org.users.save" />" style="display: none;">
<i class="fas fa-paper-plane"></i>
</button>
}
</@form.form>
</#if>
</div>
</#if>
@ -99,7 +103,7 @@
<li class="list-group-item">
@userAvatar(Some(user.name), user.avatarUrl, clazz = "user-avatar-xs")
<a class="username" href="${routes.getRouteUrl("users.showProjects", user.name)}">
@user.name
${user.name}
</a>
<p style="display: none;" class="role-id">${role.id}</p>
<#if editable && perms.has(Permission.ManageSubjectMembers) && !role.role.permissions.has(Permission.IsOrganizationOwner)>

View File

@ -4,6 +4,8 @@
<#import "*/utils/modal.ftlh" as modal />
<#import "*/utils/prompt.ftlh" as prompt />
<#import "*/utils/userAvatar.ftlh" as userAvatar />
<#import "*/utils/form.ftlh" as form>
<#import "*/utils/csrf.ftlh" as csrf>
<#--
@(u: UserData, o: Option[(OrganizationData, ScopedOrganizationData)], additionalScripts: Html = Html(""))(content: Html)(implicit messages: Messages, flash: Flash, request: OreRequest[_], config: OreConfig, assetsFinder: AssetsFinder)
@ -160,21 +162,16 @@
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal"><@spring.message "general.close" /></button>
@form(action = routes.Users.verify(Some(routes.Users.setLocked(
user = u.user.name,
locked = !u.user.isLocked,
sso = None,
sig = None
).path())), Symbol("class") -> "form-inline") {
@CSRF.formField
<@form.form method="POST" action=routes.getRouteUrl("users.verify", routes.getRouteUrl("users.setLocked", u.user.name, !u.user.isLocked, "", "")) class="form-inline">
<@csrf.formField />
<button type="submit" class="btn btn-primary"><@spring.message "general.continue" /></button>
}
</@form.form>
</div>
</@modal.modal>
<@modal.modal "user.tagline.edit" "modal-tagline" "label-tagline">
@form(action = routes.Users.saveTagline(u.user.name)) {
@CSRF.formField
<@form.form action=routes.getRouteUrl("users.saveTagline", u.user.name) method="POST">
<@csrf.formField />
<div class="modal-body">
<div class="setting setting-no-border">
<div class="setting-description">
@ -192,7 +189,7 @@
</button>
<input type="submit" value="<@spring.message "general.save" />" class="btn btn-primary" />
</div>
}
</@form.form>
</@modal.modal>
</@base.base>
</#macro>

View File

@ -1,5 +1,7 @@
<#import "/spring.ftl" as spring />
<#import "*/utils/hangar.ftlh" as hangar />
<#import "*/utils/form.ftlh" as form>
<#import "*/utils/csrf.ftlh" as csrf>
<#--
@import views.html.helper.{CSRF, form}
@ -71,10 +73,11 @@
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
@form(action = deleteCall, Symbol("class") -> "form-inline") {
@CSRF.formField
<#-- todo: where does this come from ._. -->
<@form.form action=deleteCall class="form-inline">
<@csrf.formField />
<button type="submit" class="btn btn-danger">Delete</button>
}
</@form.form>
</div>
</div>
</div>
@ -94,12 +97,13 @@
<div class="page-preview page-rendered" style="display: none ;"></div>
<#if savable>
@form(action = saveCall, Symbol("id") -> "form-editor-save") {
@CSRF.formField
<#-- todo: where does this come from ._. -->
<@form.form action=saveCall id="form-editor-save">
<@csrf.formField />
<#if extraFormValue??>
<input type="hidden" value="@extraFormValue" name="name">
</#if>
}
</@form.form>
</#if>
</#if>

View File

@ -1,5 +1,5 @@
<#macro form action method id="">
<form action="${action}" method="${method}" <#if id??>id="${id}"</#if>>
<#macro form action method id="" class="" enctype="">
<form action="${action}" method="${method}" <#if id??>id="${id}"</#if> <#if class??>class="${class}"</#if> <#if enctype??>enctype="${enctype}"</#if>>
<#nested>
</form>
</#macro>