in www/project/icla/views/pages/invite.js.rb [396:687]
def setIclaName(event)
@iclaname = event.target.value
self.checkValidity()
end
def setIclaEmail(event)
@iclaemail = event.target.value
self.checkValidity()
end
def setPMC(event)
@pmc = event.target.value
if Server.data.allData[@pmc]
@isPMC = Server.data.allData[@pmc]['pmc']
@pmcOrPPMC = @isPMC ? 'PMC' : 'PPMC'
@phase = :discuss
@subject = ''
@showPhaseFrame = true
@showRoleFrame = true
@mail_list = Server.data.allData[@pmc]['mail_list']
@display_name = Server.data.allData[@pmc]['display_name']
else
@isPMC = false
@pmcOrPPMC = '---'
@phase = :discuss
@subject = ''
@showPhaseFrame = false
@showRoleFrame = false
@mail_list = '---'
@display_name = '---'
end
self.checkValidity()
selectDiscuss()
end
def selectDiscuss(event)
@phase = :discuss
@subject = ''
@subjectPhase = '[DISCUSS]'
@previewMessage = 'Start the Discussion'
@phasePrefix = ' Start the discussion to'
@showDiscussFrame = true;
@showRoleFrame = true;
@showVoteFrame = false;
@showPMCVoteLink = false
@showPPMCVoteLink = false
@showPMCNoticeLink = false
@showPPMCNoticeLink = false
@showVoteErrorMessage = false;
@showNoticeErrorMessage = false;
self.checkValidity()
@disabled = true;
self.resetCheckBoxes()
end
def setdiscussComment(event)
@discussComment = event.target.value
end
def selectVote(event)
@phase = :vote
@subject = ''
@subjectPhase = '[VOTE]'
@previewMessage = 'Start the Vote'
@phasePrefix = ' Start the vote to'
@showVoteFrame = true;
@showRoleFrame = true;
@showDiscussFrame = false;
@showPMCVoteLink = false
@showPPMCVoteLink = false
@showPMCNoticeLink = false
@showPPMCNoticeLink = false
@showVoteErrorMessage = false;
@showNoticeErrorMessage = false;
self.checkValidity()
@disabled = true;
self.resetCheckBoxes()
end
def setvoteComment(event)
@voteComment = event.target.value
end
def selectInvite(event)
@phase = :invite
@previewMessage = 'Preview Invitation'
@showDiscussFrame = false;
@showVoteFrame = false;
@showRoleFrame = false;
@showPMCVoteLink = @isPMC
@showPPMCVoteLink = ! @isPMC
@showPMCNoticeLink = @isPMC
@showPPMCNoticeLink = ! @isPMC
@showVoteErrorMessage = false;
@showNoticeErrorMessage = false;
checkVoteLink() if document.getElementById('votelink');
checkNoticeLink() if document.getElementById('noticelink');
self.checkValidity()
end
def setVoteLink(event)
@votelink = event.target.value
@showVoteErrorMessage = false
checkVoteLink()
self.checkValidity()
end
def checkVoteLink()
document.getElementById('votelink').setCustomValidity('');
if (@votelink)
if not @votelink=~ /^https:\/\/lists\.apache\.org\//
@voteErrorMessage = "Error: Please link to\
a message via https://lists.apache.org/"
@showVoteErrorMessage = true;
end
if not @votelink=~ /private@
@voteErrorMessage = "Error: Please link to\
the [RESULT][VOTE] message sent to the private list."
@showVoteErrorMessage = true;
end
if @showVoteErrorMessage
document.getElementById('votelink').setCustomValidity(@voteErrorMessage);
end
end
end
def setNoticeLink(event)
@noticelink = event.target.value
@showNoticeErrorMessage = false;
checkNoticeLink()
self.checkValidity()
end
def checkNoticeLink()
document.getElementById('noticelink').setCustomValidity('');
if (@noticelink)
if not @noticelink=~ /^https:\/\/lists\.apache\.org\//
@noticeErrorMessage = "Error: please link to\
a message via https://lists.apache.org/"
@showNoticeErrorMessage = true;
end
if @showPMCNoticeLink and not @noticelink=~ /board@apache\.org/
@noticeErrorMessage = "Error: please link to\
the NOTICE message sent to the board list."
@showNoticeErrorMessage = true;
end
if @showPPMCNoticeLink and not @noticelink=~ /private@incubator\.apache\.org/
@noticeErrorMessage = "Error: please link to\
the NOTICE message sent to the incubator private list."
@showNoticeErrorMessage = true;
end
if @showNoticeErrorMessage
document.getElementById('noticelink').setCustomValidity(@noticeErrorMessage);
end
end
end
def setInvitation(event)
@invitation = event.target.value
self.checkValidity()
end
def checkValidity()
@disabled = !%w(iclaname iclaemail pmc votelink noticelink).all? do |id|
element = document.getElementById(id)
(not element) or element.checkValidity()
end
end
def preview()
if @phase == :invite
previewInvitation()
elsif @phase == :discuss
previewDiscussion()
elsif @phase == :vote
previewVote()
end
end
def previewInvitation()
data = {
iclaname: @iclaname,
iclaemail: @iclaemail,
pmc: @pmc,
votelink: @votelink,
noticelink: @noticelink
}
@disabled = true
@alert = nil
console.log('>previewInvitation: ' + data.inspect)
post 'validate', data do |response|
console.log('<previewInvitation: ' + response.inspect)
@disabled = false
@alert = response.error
@memberEmail = response.memberEmail
@userEmail = response.userEmail
@pmcEmail = response.pmcEmail
@invitation = response.invitation
@token = response.token
document.getElementById(response.focus).focus() if response.focus
jQuery('#invitation-preview').modal(:show) unless @alert
end
end
def previewDiscussion()
data = {
iclaname: @iclaname,
iclaemail: @iclaemail,
pmc: @pmc,
proposer: @member,
subject: @subject,
proposalText: @proposalText,
discussComment: @discussComment
}
@disabled = true
@alert = nil
console.log('>previewDiscussion: ' + data.inspect)
post 'discuss', data do |response|
console.log('<previewDiscussion: ' + response.inspect)
@disabled = false
@alert = response.error
@memberEmail = response.memberEmail
@userEmail = response.userEmail
@pmcEmail = response.pmcEmail
@discussion = response.discussion
@token = response.token
@message = response.message
document.getElementById(response.focus).focus() if response.focus
jQuery('#discussion-preview').modal(:show) unless @alert
end
end
def previewVote()
data = {
user: @user,
iclaname: @iclaname,
iclaemail: @iclaemail,
pmc: @pmc,
proposer: @member,
subject: @subject,
proposalText: @voteProposalText,
voteComment: @voteComment,
voteComment: @voteComment
}
@disabled = true
@alert = nil
console.log('>previewVote: ' + data.inspect)
post 'vote', data do |response|
console.log('<previewVote: ' + response.inspect)
@disabled = false
@alert = response.error
@memberEmail = response.memberEmail
@userEmail = response.userEmail
@pmcEmail = response.pmcEmail
@token = response.token
@message = response.message
document.getElementById(response.focus).focus() if response.focus
jQuery('#vote-preview').modal(:show) unless @alert
end
end
def mockSend()
jQuery('#invitation-preview').modal(:hide)
FormData.token = @token
FormData.fullname = @iclaname
FormData.email = @iclaemail
FormData.pmc = @pmc
FormData.votelink = @votelink
FormData.noticelink = @noticelink
history.replaceState({}, nil, "form?token=#@token")
Main.navigate(Interview)
end
end